PDA

View Full Version : Custom QHeaderView in Qt 4.1.1



Tair
11th July 2006, 09:11
Hi guys!

I'm using Qt 4.1.1 and have come across an unsolvable (at least to me) problem:
Normally text in sections of horizontal header view are drawn horizontally.
The question is - how to make that text drawn vertically, i.e. rotated by 90 degree? (see the attachment picture)
I've tried this:


class MyCustomDelegate : public QAbstractItemDelegate
{
....
public:
void paint(...){
doMyCustomPaint();
}
};
...
// usage
tableView->setModel(myModel);
myCustomDelegate = new MyCustomDelegate(this);
tableView->getHorizontalHeader()->setItemDelegate(myCustomDelegate);

But code above does not help. Have any idea?

jpn
11th July 2006, 09:19
QHeaderView is not a full-featured model-view class and doesn't unfortunately use item delegates for anything at all. Check this thread (http://www.qtcentre.org/forum/f-qt-programming-2/t-subclassing-qheaderview-2282.html).

Big Duck
11th July 2006, 09:44
I've got a similiar problem, I'd like to rotate some QPushButtons and place them vertically, similiar to Amarok or Kate sidebars on KDE.
I have looked at the Amarok source code 'multitabbar.cpp' and it subclasses the QPushbuttons and on a paint event it rotates them 90 degrees.

I wonder if this is the right way to go.