few questions related to QTreeWidget
Dear All
I have been posting to qtforum for few information on QTreeWidget but didn't find suitable solution. Please help me on the following -
1) How to set row height for QTreeWidget as in QTreeView
2) How to show(or paint) grid for QTreeWidget as in QTreeView
3)How to override default alternating row color for QTreeWidget
and
4) I need to show status in the right corner of the Toolbar. So, please suggest how to place multiple vertically stacked Qlable in that place.
Thanks.:confused: ;)
Re: few questions related to QTreeWidget
Quote:
Originally Posted by prakash
1) How to set row height for QTreeWidget as in QTreeView
2) How to show(or paint) grid for QTreeWidget as in QTreeView
QTreeWidget is a QTreeView, so you should be able to do it the same way.
Quote:
Originally Posted by prakash
3)How to override default alternating row color for QTreeWidget
Get the QPalette object using palette() method, change QPalette::AlternateBase colour and then set the modified palette using setPalette().
Quote:
Originally Posted by prakash
4) I need to show status in the right corner of the Toolbar. So, please suggest how to place multiple vertically stacked Qlable in that place.
Tool bar? Or did you mean status bar?
Re: few questions related to QTreeWidget
Yes in the Toolbar. I have 5 buttons in the toolbar. My program analyses a large file in multiple threads. I need to show how many threads are active and in which stage they are in, using QLabels in the toolbar.
Thanks.
Re: few questions related to QTreeWidget
You could try to add those labels using QToolBar::addWidget(). If you add an empty expanding QLabel first, they should be shifted to the right, but I'm not sure if it will work.
Re: few questions related to QTreeWidget
If you want to align them vertically, you'll have to put them in a layout first and add the layout to the toolbar.
Re: few questions related to QTreeWidget
There is no function to show grid for a QTreeQidget or is't parent QTreeWiew, but QTableView does have these methods. I was confused previously so Please suggest how to drowGrid and set row height in QTreeWiget.
Thanks.:)
Re: few questions related to QTreeWidget
Provide a custom delegate or reimplement QTreeView::drawRow.
Re: few questions related to QTreeWidget
Could you please provide me some sample code ?
Thanks.:cool:
Re: few questions related to QTreeWidget
How does a grid fit to a tree??
Re: few questions related to QTreeWidget
Quote:
Originally Posted by jpn
How does a grid fit to a tree??
...unless there are only top level items and root decoration is set to false, which means you have a multi-column list :)
Quote:
Originally Posted by prakash
Could you please provide me some sample code ?
If you use the custom delegate approach proposed by wysota:
override QItemDelegate::paint()
Code:
{
if (idx.isValid())
{
p->setPen(Qt::DotLine);
p->drawRect(opt.rect);
}
}
And the another approach, override QTreeView::drawRow()
Code:
{
for (int col = 0; col < columnCount(); ++col)
{
if (s.isValid())
{
QRect rect
= visualRect
(s
);
p->setPen(Qt::DotLine);
p->drawRect(rect);
}
}
}