Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set an image for a row?

Tags:

qt

I want to add text (at the beginning of a row) and an image at the end of the row.

I can set the text but how to set an image at the end of the row item in QTreeWidgetItem?

like image 205
mbr Avatar asked Sep 07 '12 10:09

mbr


People also ask

How do I display an image in a row?

Make your container div wide enough to handle all of your images. Just make the container div wide enough to accommodate all of your images and they won't wrap. Then float each image left.

How do I center an image in a row?

Method 1: Using the Text-Align Property Step 1: Since this property only works on block-level elements and not inline elements, let's start by wrapping the image in a block element. Step 2: Wrap the image in a div and then apply the style attribute with the text-align property set to center.

How do I put two pictures in a row?

Click and drag the second image next to the first, where you want it to align. As the sides come close to each other, Word will automatically snap the second image into place next to the first. Release the mouse button when the images are aligned next to each other as you need them to be.


1 Answers

Just set for example two columns in QTreeWidget and then set text in first one and icon in second one:

QTreeWidgetItem *newItem = new QTreeWidgetItem;
newItem->setText(0, "Something");
newItem->setIcon(1, QIcon("Path to your icon"));

myTreeWidget->addTopLeveItem(newItem);

Or instread of setting icon you can just set foreground:

newItem->setForeground(QBrush(QPixmap("Path to your image")));

which may be better for your problem.

like image 77
Blood Avatar answered Oct 13 '22 19:10

Blood