chengxr 1 year ago
parent
commit
410cd7465e
3 changed files with 61 additions and 6 deletions
  1. 0 1
      QFD/view/ExpertManageView.cpp
  2. 48 5
      QFD/widgets/ExpertListWidget.cpp
  3. 13 0
      QFD/widgets/ExpertListWidget.h

+ 0 - 1
QFD/view/ExpertManageView.cpp

@@ -47,7 +47,6 @@ void ExpertManageView::initLayout()
     m_hBoxLayout->addWidget(m_searchLineEdit, 0, Qt::AlignLeft);
     m_hBoxLayout->addWidget(m_addExpertPushButton, 1, Qt::AlignLeft);
 
-    m_vBoxLayout->addSpacing(15);
     m_vBoxLayout->addWidget(m_expertListWidget);
 }
 

+ 48 - 5
QFD/widgets/ExpertListWidget.cpp

@@ -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);
 }

+ 13 - 0
QFD/widgets/ExpertListWidget.h

@@ -3,6 +3,9 @@
 
 #include <QWidget>
 
+class QVBoxLayout;
+class QListWidget;
+
 ///
 /// \brief The ExpertListWidget class
 /// 专家列表
@@ -12,7 +15,17 @@ class ExpertListWidget : public QWidget
 public:
     explicit ExpertListWidget(QWidget *parent = nullptr);
 
+    void refreshList();
+
 signals:
+
+private:
+    void initialize();
+    void initLayout();
+
+private:
+    QVBoxLayout *m_vBoxLayout       = nullptr;
+    QListWidget *m_expertListWidget = nullptr;
 };
 
 #endif  // EXPERTLISTWIDGET_H