|
@@ -1,13 +1,56 @@
|
|
|
#include "ExpertListWidget.h"
|
|
|
|
|
|
+#include <QBoxLayout>
|
|
|
+#include <QListWidget>
|
|
|
#include <QLabel>
|
|
|
|
|
|
ExpertListWidget::ExpertListWidget(QWidget *parent) : QWidget(parent)
|
|
|
{
|
|
|
- setFixedSize(QSize(300, 300));
|
|
|
+ initialize();
|
|
|
+ initLayout();
|
|
|
+ refreshList();
|
|
|
+}
|
|
|
+
|
|
|
+void ExpertListWidget::refreshList()
|
|
|
+{
|
|
|
+ m_expertListWidget->clear();
|
|
|
|
|
|
- QPalette pal(palette());
|
|
|
- pal.setColor(QPalette::Background, QColor("#ffff00"));
|
|
|
- setAutoFillBackground(true);
|
|
|
- setPalette(pal);
|
|
|
+ for (int i = 1; i <= 100; i++) {
|
|
|
+ QListWidgetItem *item = new QListWidgetItem;
|
|
|
+ item->setSizeHint(QSize(200, 60));
|
|
|
+ m_expertListWidget->addItem(item);
|
|
|
+
|
|
|
+ QWidget *w = new QWidget();
|
|
|
+ w->setStyleSheet("border: 1px solid rgba(0, 0, 0, 0)");
|
|
|
+ if (i % 2 == 0) {
|
|
|
+ // w->setStyleSheet("QWidget {background-color: rgb(250, 250, 250);border: 1px solid rgba(0, 0,
|
|
|
+ // 0, 0);}"
|
|
|
+ // "QLabel {border: 1px solid rgba(0, 0, 0, 0)}");
|
|
|
+ } else {
|
|
|
+ w->setStyleSheet("QWidget {background-color: rgb(244, 244, 255);border: 1px solid rgba(0, 0, 0, 0);}"
|
|
|
+ "QLabel {border: 1px solid rgba(0, 0, 0, 0)}"
|
|
|
+ "QWidget::hover {background-color: rgb(244, 244, 0);}");
|
|
|
+ }
|
|
|
+ m_expertListWidget->setItemWidget(item, w);
|
|
|
+
|
|
|
+ QHBoxLayout *hBox = new QHBoxLayout(w);
|
|
|
+ hBox->setSpacing(0);
|
|
|
+ hBox->setMargin(0);
|
|
|
+ hBox->addWidget(new QLabel(QString::number(i)));
|
|
|
+ hBox->addSpacing(10);
|
|
|
+ hBox->addWidget(new QLabel(QString("专家%1").arg(i)));
|
|
|
+ hBox->addStretch();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void ExpertListWidget::initialize()
|
|
|
+{
|
|
|
+ m_vBoxLayout = new QVBoxLayout(this);
|
|
|
+ m_expertListWidget = new QListWidget(this);
|
|
|
+ m_expertListWidget->setStyleSheet("border: 1px solid rgba(0, 0, 0, 0.073)");
|
|
|
+}
|
|
|
+
|
|
|
+void ExpertListWidget::initLayout()
|
|
|
+{
|
|
|
+ m_vBoxLayout->addWidget(m_expertListWidget);
|
|
|
}
|