August 30, 2010

tineu tineu
Lab Rat
3 posts

align icon on a tab (QTabWidget) & tab widths

 

Defaut is left aligned. Cannot change this through style sheets – I want it center aligned. Is there any sample code for this?

Can each (individual) tab size be changed (width)?

7 replies

August 30, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

by default the icon and text are center aligned. remove text and see if the icon comes to the left or center.

Can each (individual) tab size be changed (width)?

do you mean tab headers or varying width with individual tab pages

August 30, 2010

tineu tineu
Lab Rat
3 posts

I don’t have any text. Only icons which are definately left aligned (Qt4.6). I added the icons in QtCreator UI and in code, same thing. In style sheets there are no alignments.

Width: Individial tab (with an icon in it). If I set the width of the icon, every tab width changes to the same value. For instance: If there are 5 tabs – each 20px wide. If width of any tab is changed, all tabs reset to the same width.

edit:

To demonstrate I’ve created a new project with QTabWidget and one icon (no style sheets or aditional code)

http://i38.tinypic.com/zj8pll.jpg [i38.tinypic.com]

August 30, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

try something like this,

extend tab widget, and in the QTabBar, call setTabButton on individual index, with your custom widget

August 30, 2010

tineu tineu
Lab Rat
3 posts

If I understand correctly you are saying I should subclass QTabWidget so I have access to the tabBar, then create a custom widget (ie QLabel static casted to button) and add it through “setTabButton”?

Either way I’m quite new at Qt – could you help me out with a sample code maybe? I’d appriciate it.

August 30, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

ok sure, but might take sometime as am busy with few other things too :)

August 31, 2010

tineu tineu
Lab Rat
3 posts

As I stated – any help is appriciated. Thank you in advance.

September 1, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

I put up something quickly here [developer.qt.nokia.com], with just one tab button, but something you can extend upon.. is this what you wanted?

 
  ‹‹ [Moved] I can’s limited the size of custum widget inherited Qwidget in mainwindow      [Moved] How to QGraphicsView receive keyPressEvent to active a QState ››

You must log in to post a reply. Not a member yet? Register here!