how to show vertical lines between colums
hi all
i am using Qt4.1 on Mac OS
the idea is to showing the vertical lines between colums of QTreeWidget
as i have 4 colums in treewidget.
how it can be done???
and how data coming in all colums should be aligned squarely or in proper manner???
thanks in advance
Re: how to show vertical lines between colums
I don't think there's any built-in way for doing that. What you can do is to reimplement paintEvent() and paint them yourself. The header provides information about column (section) positions and sizes.
Re: how to show vertical lines between colums
can you please explai how it can be done in simple example with no. of items are there in TreeWidget
Re: how to show vertical lines between colums
Alright, here's an example:
Code:
#include <QtGui>
{
public:
{
setColumnCount(5);
}
protected:
{
for (int i = 0; i < header()->count(); ++i)
{
// draw only visible sections starting from second column
if (header()->isSectionHidden(i) || header()->visualIndex(i) <= 0)
continue;
// position mapped to viewport
int pos = header()->sectionViewportPosition(i) - 1;
if (pos > 0)
}
}
void scrollContentsBy(int dx, int dy)
{
// make sure lines get updated even if the view is empty
viewport()->update();
}
};
int main(int argc, char *argv[])
{
TreeWidget tree;
tree.show();
return app.exec();
}
You could use for example QStyle::SH_Table_GridLineColor as pen color.
Re: how to show vertical lines between colums
thanks for such a nice example
but i dont have to use qpen or Qpaint properties...
can we disable the streching of treewidget's header
i.e header should be of fixed width