How can i add some description about current QtreeWidgetItem inside QtreeWidgetItem
Hai,
I need to display some icons and information when click on current QtreeWidgetItem
ex: code
Code:
for(int i=0; i<10; i++)
{
ui->secTreeWidget->addTopLevelItem(parent);
// Add the child TreeWidgetItem one step down in the tree
parent->addChild(child);
// Set the widget for the child item to be a QLineEdit for column zero.
ui
->secTreeWidget
->setItemWidget
(child,
0,
new QLabel(ui
->secTreeWidget
));
}
Re: How can i add some description about current QtreeWidgetItem inside QtreeWidgetIt
Re: How can i add some description about current QtreeWidgetItem inside QtreeWidgetIt
When we click on an item we need to display some lines of text and symbols below the clicked item.
Re: How can i add some description about current QtreeWidgetItem inside QtreeWidgetIt
I asked what is the question, and you tell me what you want to do - that is not a question, but an assertion.
What is the problem you are having?
What do you mean "below the clicked item"?
Should it be part of the item?
Should it be in the tree context?
Do you mean like a tooltip maybe?
If you want help, provide enough information to help you.
Re: How can i add some description about current QtreeWidgetItem inside QtreeWidgetIt
Code:
...
...
{
index.data( Qt::DisplayRole ); - text
index.data( Qt::DecorationRole ); - icon
etc..........
}
1 Attachment(s)
Re: How can i add some description about current QtreeWidgetItem inside QtreeWidgetIt
Attachment 7461
We need to display some contents (some text and symbols)below the Wit Name
sample code is below:
Code:
for(int i=0; i<3; i++)
{
ui->firstTreeWidget->addTopLevelItem(parent);
parent
->setIcon
( 0,
QPixmap::fromImage( QImage("images/heart.png") ) );
// Add the child TreeWidgetItem one step down in the tree
parent->addChild(child);
// Set the widget for the child item to be a QLineEdit for column zero.
ui
->firstTreeWidget
->setItemWidget
(child,
0,
new QLabel(ui
->firstTreeWidget
));
}
for(int i=0; i<1; i++)
{
ui->secTreeWidget->addTopLevelItem(parent);
// Add the child TreeWidgetItem one step down in the tree
parent->addChild(child);
// Set the widget for the child item to be a QLineEdit for column zero.
ui
->secTreeWidget
->setItemWidget
(child,
0,
new QLabel(ui
->secTreeWidget
));
}
for(int i=0; i<5; i++)
{
ui->thirdTreeWidget->addTopLevelItem(parent);
// Add the child TreeWidgetItem one step down in the tree
parent->addChild(child);
// Set the widget for the child item to be a QLineEdit for column zero.
ui
->thirdTreeWidget
->setItemWidget
(child,
0,
new QLabel(ui
->thirdTreeWidget
));
}
Re: How can i add some description about current QtreeWidgetItem inside QtreeWidgetIt
So you want to add children to WitName - but it seems you know how to do that, based on the code you posted.
So what is the problem?
1 Attachment(s)
Re: How can i add some description about current QtreeWidgetItem inside QtreeWidgetIt
yes.. need to add children to Wit Name,also we need to add some symbols and text below the Wit Name.The following image is our expected Ui Design.Please see the image.I expect your valuable suggestions for creating the same.
Re: How can i add some description about current QtreeWidgetItem inside QtreeWidgetIt
Why don't you answer my questions?
Re: How can i add some description about current QtreeWidgetItem inside QtreeWidgetIt
Sorry..Problem is not able to add some text and Symbols below the Wit name.How can I add this?
Its part of the current Wit Name.Its not a tool tip.
Re: How can i add some description about current QtreeWidgetItem inside QtreeWidgetIt
I am not sure that I follow - you just add new tree (child) items - and your code is doing that already (you just are not specifying any content to the labels in the items so they are empty) ...
Either I don't understand you, or you don't understand the code you posted - it already does what you want (as I understand you correctly), you just have to populate it with the data you want displayed.
Re: How can i add some description about current QtreeWidgetItem inside QtreeWidgetIt
Quote:
Originally Posted by
high_flyer
I am not sure that I follow - you just add new tree (child) items - and your code is doing that already (you just are not specifying any content to the labels in the items so they are empty) ...
Either I don't understand you, or you don't understand the code you posted - it already does what you want (as I understand you correctly), you just have to populate it with the data you want displayed.
I think the problem is that the OP wants to display more than just a line of text; it isn't just as simple as adding a new child item to the tree.
@vinayaka: Look at QTreeWidget::setItemWidget(). If you create a custom widget that contains what you want (labels, text, etc.), you can then set that at the appropriate place in your tree. When that node in the tree is opened, the widget will be displayed.
I am sure you will need to change the contents at run time, since it looks like you are trying to display dynamic contents. So also look at using QTextEdit as the item widget. You will format your text and other information (like symbols and hyperlinks) using the QTextDocument controlled by the QTextEdit.
This will not be simple to do, but then you are asking for a UI that is not simple. And no, I cannot provide you with example code. The Qt documentation contains several tutorials and examples on how to use QTextDocument and QTextEdit.