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
?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With