PDA

View Full Version : QtoolButton stylesheet styling



conti
21st September 2012, 11:09
Hi what im trying to do is aligning the text and icon in a ToolButton to the left.
What i have is a vertical Toolbar configured like this:
mtoolBar->setOrientation( Qt::Vertical );
mtoolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
mtoolBar->setStyleSheet("QToolBar { border: 0px } QToolButton { text-align:left}");

I want to have Icons and Text in the tool buttons so i use Qt::ToolButtonTextBesideIcon, but this also has the effect that the content of the toolbuttons gets centered. This looks realy ugly when i have toolbutton texts with different lengths. How can i achive what i am trying to do with the stylesheet ( align the content to the left) ?

Thanks

*edit*
I fixed it this way:
mtoolBar->setStyleSheet("QToolBar { border: 0px } QToolButton { width: 100%}");

Amitoj
29th June 2013, 09:13
Thanks. I was having the exact same problem, and the obviously the same solution worked :)