1 Attachment(s)
To add QTreeWidgetItem with two Stringsand with different fonts in a QTreeWidgetItem.
Hi,
I am working on Qt4.3.4 on my mac . I want to add an item in QTreeWidget , but QTreeWidgetItem should contain two strings - One String is of greater font than the other and other string is in next line and of smaller font, and also how to get the value of the second string. Image file is attached, for the reference. I want to add item in the QTreeWidget in the way it is in the File Attached.
Thanks,
Re: To add QTreeWidgetItem with two Stringsand with different fonts in a QTreeWidgetI
You have two possibilities: a) use a custom delegate (recommended option) b) use QTreeWidget::setItemWidget().
Re: To add QTreeWidgetItem with two Stringsand with different fonts in a QTreeWidgetI
Thanks for the reply. Can you pls explain it with an example.....how can i use custom delegate.
Re: To add QTreeWidgetItem with two Stringsand with different fonts in a QTreeWidgetI
A starting point is "Model/View Programming! in the docs. If you have a more specific question, ask again.
Re: To add QTreeWidgetItem with two Stringsand with different fonts in a QTreeWidgetI
Yaa actually I had two strings eg. "String1" and "String2" I had inserted these strings in a QTreeWidget
Code:
item1->setText(0,"String1");
tem1->setFont(0,font1);
item2->setText(0,"String2");
tem1->setFont(0,font2);
The output is:
String1
String2
String1 is the parent of String2 and treeWidget is parent of String1
But I want both the strings should be of the same parent, but should be split and with the different fonts. That I had shown in the Attached file.
Re: To add QTreeWidgetItem with two Stringsand with different fonts in a QTreeWidgetI
Please use the [code] tags next time. And in your code I can't see a custom delegate nor setItemWidget(). So if you don't try what I suggest you, I really can't help you. I won't provide a ready to use solution!