完成了元素池的窗口
parent
a28e484cb2
commit
53025b93e4
|
@ -3,26 +3,29 @@
|
||||||
ElementPoolWidget::ElementPoolWidget(QWidget* parent)
|
ElementPoolWidget::ElementPoolWidget(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
iconWidth = 30, iconHeight = 40;
|
iconWidth = 150, iconHeight = 100;
|
||||||
pictureList = new QListWidget(this);
|
pictureList = new QListWidget(this);
|
||||||
pictureList->setIconSize(QSize(iconWidth, iconHeight));
|
pictureList->setIconSize(QSize(iconWidth, iconHeight));
|
||||||
pictureList->setResizeMode(QListView::Adjust);
|
pictureList->setResizeMode(QListView::Adjust);
|
||||||
pictureList->setViewMode(QListView::IconMode);
|
pictureList->setViewMode(QListView::IconMode);
|
||||||
pictureList->setMovement(QListView::Static);
|
pictureList->setMovement(QListView::Static);
|
||||||
pictureList->setSpacing(10);
|
pictureList->setSpacing(10);
|
||||||
|
pictureList->setFixedSize(600, 800);
|
||||||
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
|
||||||
connect(pictureList, SIGNAL(vitemClicked(QListWidgetItem*)), this, SLOT(pictureItemClicked(QListWidgetItem*)));
|
connect(pictureList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(pictureItemClicked(QListWidgetItem*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementPoolWidget::setElementList(std::vector<GraphicElement*> elements) {
|
void ElementPoolWidget::setElementList(std::vector<GraphicElement*> elements) {
|
||||||
pictureList->clear();
|
pictureList->clear();
|
||||||
for (int index = 0; index < elements.size(); index++) {
|
for (int index = 0; index < elements.size(); index++) {
|
||||||
QString strPath = QString("D:\\BigC\\Project\\ArchitectureColoredPainting\\svg\\test.svg");
|
//
|
||||||
QPixmap itemPixmap(strPath);
|
//QString strPath = QString("C:\\Users\\86177\\Pictures\\Screenshots\\test.png");
|
||||||
|
//QPixmap itemPixmap(strPath);
|
||||||
|
QPixmap itemPixmap = elements[index]->getPaintObject().getPixmap();
|
||||||
QListWidgetItem* pItem = new QListWidgetItem(
|
QListWidgetItem* pItem = new QListWidgetItem(
|
||||||
itemPixmap.scaled(QSize(iconWidth, iconHeight)),
|
itemPixmap.scaled(QSize(iconWidth-20, iconHeight-20)),
|
||||||
elements[index]->name);
|
elements[index]->name);
|
||||||
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
||||||
pictureList->insertItem(index, pItem);
|
pictureList->insertItem(index, pItem);
|
||||||
|
@ -34,5 +37,6 @@ ElementPoolWidget::~ElementPoolWidget() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ElementPoolWidget::pictureItemClicked(QListWidgetItem* item) {
|
int ElementPoolWidget::pictureItemClicked(QListWidgetItem* item) {
|
||||||
|
//qDebug() << pictureList->currentRow();
|
||||||
return pictureList->currentRow();
|
return pictureList->currentRow();
|
||||||
}
|
}
|
|
@ -97,11 +97,26 @@ namespace UnitTest
|
||||||
};
|
};
|
||||||
TEST_CLASS(ElementPoolTest)
|
TEST_CLASS(ElementPoolTest)
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
char* argv[1];
|
||||||
|
int argc;
|
||||||
public:
|
public:
|
||||||
|
ElementPoolTest() :argv{ (char*)"" }, argc(1) {}
|
||||||
|
|
||||||
|
TEST_METHOD_INITIALIZE(initialize)
|
||||||
|
{
|
||||||
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
|
}
|
||||||
TEST_METHOD(ElementPool) {
|
TEST_METHOD(ElementPool) {
|
||||||
|
QApplication a(argc, argv);
|
||||||
qInstallMessageHandler(messageHandler);
|
qInstallMessageHandler(messageHandler);
|
||||||
ElementPoolWidget wi;
|
ElementPoolWidget wi;
|
||||||
|
wi.setElementList({"1", "2", "3"});
|
||||||
|
wi.setFixedSize(QSize(600, 800));
|
||||||
wi.show();
|
wi.show();
|
||||||
|
a.exec();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue