Maybe you can tweak the TabBar position using a custom QStyle.
I know there are some elements you can reimplement in there :
http://doc.trolltech.com/4.2/qstyle....ubElement-enum
Maybe you can tweak the TabBar position using a custom QStyle.
I know there are some elements you can reimplement in there :
http://doc.trolltech.com/4.2/qstyle....ubElement-enum
Thanks for the tip. I'm trying to do something like this, but unfortunately it is not centering it:
Qt Code:
int CenterTab::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const { switch (hint) { case SH_TabBar_Alignment: return int(Qt::AlignHCenter); default: } }To copy to clipboard, switch view to plain text mode
Any pointers?
If you are using a QTabWidget I would try out
If you set one expanding widget in each corner, that might center the tabs. If you are not using QTabWidget, you can still have a look at the source code for the above function and do it yourself.Qt Code:
To copy to clipboard, switch view to plain text mode
spud, i've been looking into your advice...but I can't seem to understand how to make an expandable widget...can you explain a bit more please?
I'm trying to do something similar to what I demonstrate below...however the size hint is not correctly being shown:
Create a CenterTab class which will be used as the TopLeftCorner widget:
Qt Code:
{ QOBJECT public: CenterTab(int width, int height); protected: private: int width; int height; } CenterTab::CenterTab(int width, int height) { width = width; height = height; } { }To copy to clipboard, switch view to plain text mode
Then within your QTabWidget constructor:
Qt Code:
centerTab = new CenterTab(100, 25); // You can use any width and height you like this->setCornerWidget(centerTab, Qt::TopLeftCorner);To copy to clipboard, switch view to plain text mode
Thanks for the help guys...
Last edited by forrestfsu; 13th March 2007 at 22:04.
Ha, great. I got it...the above works as long as you change:
Qt Code:
width= width; height=height;To copy to clipboard, switch view to plain text mode
to:
Qt Code:
this->width= width; this->height=height;To copy to clipboard, switch view to plain text mode
It was a silly mistake. Thanks for all the help!
Your code won't center tabs unless there is only a fixed number. You'd better compute the size hint of your center widget according to the number of tabs (or better to their actual size)...
Current Qt projects : QCodeEdit, RotiDeCode
thanks fullmetalcoder...I have already taken that into account in my code. I just gave an example of what I did above incase anyone else runs into the same problem.
Bookmarks