#include <QApplication>
#include <QWidget>
#include <QComboBox>
#include <QVBoxLayout>
int main(int argc, char *argv[])
{
//QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
//QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, false);
bool useIcon = true;
bool usePixmap = false;
for(int i = 0; i < 20; ++i)
{
if(useIcon)
{
if(usePixmap)
{
box
->addItem
(QIcon(QPixmap(":/img/android-add-contact.png")),
QObject::tr("Box %1 - 2").
arg(i
));
box
->addItem
(QIcon(QPixmap(":/img/database-symbol-md.png")),
QObject::tr("Box %1 - 4").
arg(i
));
box
->addItem
(QIcon(QPixmap(":/img/Devices-printer-icon.png")),
QObject::tr("Box %1 - 5").
arg(i
));
}
else
{
box
->addItem
(QIcon(":/img/about-icon.png"),
QObject::tr("Box %1 - 1").
arg(i
));
box
->addItem
(QIcon(":/img/android-add-contact.png"),
QObject::tr("Box %1 - 2").
arg(i
));
box
->addItem
(QIcon(":/img/Bug.png"),
QObject::tr("Box %1 - 3").
arg(i
));
box
->addItem
(QIcon(":/img/database-symbol-md.png"),
QObject::tr("Box %1 - 4").
arg(i
));
box
->addItem
(QIcon(":/img/Devices-printer-icon.png"),
QObject::tr("Box %1 - 5").
arg(i
));
}
}
else
{
box
->addItem
(QObject::tr("Box %1 - 1").
arg(i
));
box
->addItem
(QObject::tr("Box %1 - 2").
arg(i
));
box
->addItem
(QObject::tr("Box %1 - 3").
arg(i
));
box
->addItem
(QObject::tr("Box %1 - 4").
arg(i
));
box
->addItem
(QObject::tr("Box %1 - 5").
arg(i
));
}
layout->addWidget(box);
}
mainWidget.setLayout(layout);
mainWidget.show();
return a.exec();
}
#include <QApplication>
#include <QWidget>
#include <QComboBox>
#include <QVBoxLayout>
int main(int argc, char *argv[])
{
//QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
//QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, false);
QApplication a(argc, argv);
bool useIcon = true;
bool usePixmap = false;
QWidget mainWidget;
QVBoxLayout *layout = new QVBoxLayout;
for(int i = 0; i < 20; ++i)
{
QComboBox *box = new QComboBox;
box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
if(useIcon)
{
if(usePixmap)
{
box->addItem(QIcon(QPixmap(":/img/about-icon.png")), QObject::tr("Box %1 - 1").arg(i));
box->addItem(QIcon(QPixmap(":/img/android-add-contact.png")), QObject::tr("Box %1 - 2").arg(i));
box->addItem(QIcon(QPixmap(":/img/Bug.png")), QObject::tr("Box %1 - 3").arg(i));
box->addItem(QIcon(QPixmap(":/img/database-symbol-md.png")), QObject::tr("Box %1 - 4").arg(i));
box->addItem(QIcon(QPixmap(":/img/Devices-printer-icon.png")), QObject::tr("Box %1 - 5").arg(i));
}
else
{
box->addItem(QIcon(":/img/about-icon.png"), QObject::tr("Box %1 - 1").arg(i));
box->addItem(QIcon(":/img/android-add-contact.png"), QObject::tr("Box %1 - 2").arg(i));
box->addItem(QIcon(":/img/Bug.png"), QObject::tr("Box %1 - 3").arg(i));
box->addItem(QIcon(":/img/database-symbol-md.png"), QObject::tr("Box %1 - 4").arg(i));
box->addItem(QIcon(":/img/Devices-printer-icon.png"), QObject::tr("Box %1 - 5").arg(i));
}
}
else
{
box->addItem(QObject::tr("Box %1 - 1").arg(i));
box->addItem(QObject::tr("Box %1 - 2").arg(i));
box->addItem(QObject::tr("Box %1 - 3").arg(i));
box->addItem(QObject::tr("Box %1 - 4").arg(i));
box->addItem(QObject::tr("Box %1 - 5").arg(i));
}
layout->addWidget(box);
}
mainWidget.setLayout(layout);
mainWidget.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks