Unsolved How to add QLabel or set text custom into QListWidget?
-
Hello, as you will see in the photo, I would like to add QLabel to the marked place. But I couldn't do it, I found this;
QListView::item:text { color: #a87272; position: relative; top: 5px; left: 5px; }
I am doing this but top and left are not working I hope you understand what I want, please help. -
Someone help me? Please...
-
@jsulm Can you look, sir?
-
Hi and welcome to devnet,
Please show some patience and allow at least 24 hours to pass before bumping your own thread. This forum is run by volunteers who might not live in the same timezone as you.
As for your issue, why do you want to add a QLabel there ?
-
@SGaist I will put a data in your program with QLabel. It looks good in design.
-
You have a QListView, which means you have a model underneath then why not put these data in your model and for custom rendering use QStyledItemDelegate ?
-
i using QListWidgetItem;
QString webSite = "httpblabla...";
QString data = DownloadHTTPData(webSite);
dataLabel = new QLabel(data);
item = new QListWidgetItem();
item->setIcon(...);
if(data == "1")
{
item->setIcon(...2);
item->setText(dataLabel); // Here I want to create a QLabel and bring it to the specified location.
ui->listWidget->addItem(item);
}(I'm also new to QT.)
-
That's the wrong way to implement it.
Since you want to put stuff at specific places, implement a custom QStyledItemDelegate so you'll be able to paint thing where you want to have them.