I have to create an Icon pixmap, two methods I am familiarized to do that, One is setting the pixmap as o QLabel
and display it, and other is drawing pixmap using QPainter
, ie
Method one
Icon::Icon
{
QLabel iconLab = new QLabel;
QLabel iconName = new QLabel;
iconLab->setPixmap("mypixmap.png");
iconName->setText("myiconname");
QVBoxLayout *iconLayout = new QVBoxLayout;
iconLayout->setMargin(0);
iconLayout->addWidget(iconLab, 1, Qt::AlignCenter);
iconLayout->addWidget(iconName, 1, Qt::AlignCenter);
iconLayout->setSpacing(0);
setLayout(iconLayout);
setMaximumSize(100,160);
setMinimumSize(100,160);
}
Method 2,
Icon::Icon
{
setMaximumSize(100,160);
setMinimumSize(100,160);
}
Icon::paintEvent(QPaintEvent*)
{
QPainter painter;
painter.drawPixmap(0,0,myPixmap);
painter.drawText(0,100,myText)
}
I have to draw number of Icons, more than 100, so which one is effective, Thanks in advance,