添加了右侧栏的StyleList样例
parent
ef88c4a39e
commit
7d0ca047c1
|
@ -1,6 +1,9 @@
|
||||||
#include "InfoDisplayWidget.h"
|
#include "InfoDisplayWidget.h"
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
void InfoDisplayWidget::setLayer(LayerWrapper *layer)
|
void InfoDisplayWidget::setLayer(LayerWrapper *layer)
|
||||||
{
|
{
|
||||||
this->displayLayer = layer;
|
this->displayLayer = layer;
|
||||||
|
@ -72,9 +75,47 @@ void InfoDisplayWidget::generateLayerForm()
|
||||||
layout->addRow("scale-X:", scaleX);
|
layout->addRow("scale-X:", scaleX);
|
||||||
layout->addRow("scale-Y:", scaleY);
|
layout->addRow("scale-Y:", scaleY);
|
||||||
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
|
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
|
||||||
|
|
||||||
|
bool styleEnabled = true;
|
||||||
|
if (styleEnabled) {
|
||||||
|
QListWidget* styleList = new QListWidget(this);
|
||||||
|
QListWidgetItem* item = new QListWidgetItem("样式列表");
|
||||||
|
item->setFlags(Qt::NoItemFlags);
|
||||||
|
styleList->addItem(item);
|
||||||
|
static vector<QString> styleNames = { "样例1", "样例2", "样例3" };
|
||||||
|
auto createStyleItem = [this, styleList](int index) {
|
||||||
|
QListWidgetItem* item = new QListWidgetItem;
|
||||||
|
QWidget* w = new QWidget;
|
||||||
|
item->setSizeHint(QSize(50, 40));
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout;
|
||||||
|
QPushButton* pushButton = new QPushButton(w);
|
||||||
|
QLabel* name = new QLabel(w);
|
||||||
|
name->setText(styleNames[index]);
|
||||||
|
pushButton->setText("×");
|
||||||
|
pushButton->setFixedSize(QSize(20, 20));
|
||||||
|
connect(pushButton, &QPushButton::clicked, [styleList,item,this]() {
|
||||||
|
styleList->removeItemWidget(item);
|
||||||
|
delete item;
|
||||||
|
// delete data in layer
|
||||||
|
emit requireRefreshPreview();
|
||||||
|
});
|
||||||
|
layout->addWidget(name);
|
||||||
|
layout->addWidget(pushButton);
|
||||||
|
w->setLayout(layout);
|
||||||
|
styleList->addItem(item);
|
||||||
|
styleList->setItemWidget(item, w);
|
||||||
|
};
|
||||||
|
for (int i = 0; i < styleNames.size(); i++)
|
||||||
|
createStyleItem(i);
|
||||||
|
|
||||||
|
|
||||||
|
layout->addRow(styleList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InfoDisplayWidget::generateElementForm()
|
void InfoDisplayWidget::generateElementForm()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue