Compare commits
2 Commits
a28e484cb2
...
6a4a724f00
Author | SHA1 | Date |
---|---|---|
yang.yongquan | 6a4a724f00 | |
yang.yongquan | 53025b93e4 |
|
@ -3,26 +3,29 @@
|
|||
ElementPoolWidget::ElementPoolWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
iconWidth = 30, iconHeight = 40;
|
||||
iconWidth = 150, iconHeight = 100;
|
||||
pictureList = new QListWidget(this);
|
||||
pictureList->setIconSize(QSize(iconWidth, iconHeight));
|
||||
pictureList->setResizeMode(QListView::Adjust);
|
||||
pictureList->setViewMode(QListView::IconMode);
|
||||
pictureList->setMovement(QListView::Static);
|
||||
pictureList->setSpacing(10);
|
||||
pictureList->setFixedSize(600, 800);
|
||||
|
||||
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) {
|
||||
pictureList->clear();
|
||||
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(
|
||||
itemPixmap.scaled(QSize(iconWidth, iconHeight)),
|
||||
itemPixmap.scaled(QSize(iconWidth-20, iconHeight-20)),
|
||||
elements[index]->name);
|
||||
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
||||
pictureList->insertItem(index, pItem);
|
||||
|
@ -34,5 +37,6 @@ ElementPoolWidget::~ElementPoolWidget() {
|
|||
}
|
||||
|
||||
int ElementPoolWidget::pictureItemClicked(QListWidgetItem* item) {
|
||||
//qDebug() << pictureList->currentRow();
|
||||
return pictureList->currentRow();
|
||||
}
|
|
@ -97,11 +97,26 @@ namespace UnitTest
|
|||
};
|
||||
TEST_CLASS(ElementPoolTest)
|
||||
{
|
||||
private:
|
||||
char* argv[1];
|
||||
int argc;
|
||||
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) {
|
||||
QApplication a(argc, argv);
|
||||
qInstallMessageHandler(messageHandler);
|
||||
ElementPoolWidget wi;
|
||||
//wi.setElementList({"1", "2", "3"});
|
||||
wi.setFixedSize(QSize(600, 800));
|
||||
wi.show();
|
||||
a.exec();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue