Unsolved I want to display text and image inside the listwidget (as thumbnail)
-
I have a listwidget and i am making the listwidget as a thumbnail of the combination as text and image but the sequence of this is text followed by the image. But I am getting the sequence as image followed by text. I am using this one code for this :
listWidget->addItem(new QListWidgetItem(QIcon(QPixmap::fromImage(Image)),String));
also, I am attaching the image view for this:
-
hi
so question is
How do i get the text on top of image or ? -
@mrjj yes but an index of listwidget is same for text and image (here the only 6 index is there, but when I try to put text and image as an item then the listwidget index takes 1 index for everyone
-
@amarism
Im not sure what you mean with 1 index.Each item has text and icon.
-
@mrj I am taking 6 images. So, the index is from (0-5). But when I put text and image as item then all item taking 1-1 index I want too set the listwidget index equal to a number of the image.
-
@amarism
well
listWidget->addItem(new QListWidgetItem ..
should handle that automtically. -
@mrjj This one method
QListWidgetItem(const QIcon & icon, const QString & text, QListWidget * parent = 0, int type = Type)
but i want to take item value like ( Text and Image). -
@amarism
but its just
Icon and text. why should that matter ? -
Hi
Try setting
item->setTextAlignment(Qt::AlignTop);
and see if that works.Update: it wont. still under when icon mode.
-
Hi
I could be wrong but i think to have text over, you need a delegate and draw it.
(unless someone knows how to make it use TextAlignment in iconmode)https://forum.qt.io/topic/92857/icon-in-corner-of-qstandarditem/5
the SmallIconDelegate should be excellent starting point.
start with
http://doc.qt.io/qt-5/qitemdelegate.html