PDA

View Full Version : QToolButton + style sheet problem



John82
3rd July 2009, 02:47
Does anyone know if this is correct?


tb = new QToolButton (_viewGroup);
tb->setText ("Trial");
tb->setFixedWidth (150);
tb->setFixedHeight (40);
tb->setArrowType (Qt::DownArrow);
tb->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

// This section here ???
tb->setStyleSheet ("down-arrow: subcontrol-position: right center");

I want to move the arrow to the right

aamer4yu
3rd July 2009, 08:10
I dont know.. but if it works, it might be right :D

John82
3rd July 2009, 08:17
I dont know.. but if it works, it might be right :D

uhm it doesn't work. Sorry if the wording on my post was wrong. But I want to know how to use that function call to move the "arrow" in a QToolButton to the right side of the button.

Lykurg
3rd July 2009, 10:52
[CODE]tb->setStyleSheet ("down-arrow: subcontrol-position: right center");[/CODE
You should take a closer look at the syntax of css. I don't have checked if your commands work but one right syntax is:
QToolButton::down-arrow{subcontrol-position: right center;}

John82
3rd July 2009, 16:13
You should take a closer look at the syntax of css. I don't have checked if your commands work but one right syntax is:
QToolButton::down-arrow{subcontrol-position: right center;}

I tried this. I wrote the above line in a .qss file and read it. But it didnt work, that is why I am am looking for a direct implementation.

Lykurg
3rd July 2009, 16:17
I tried this. I wrote the above line in a .qss file and read it. But it didnt work, that is why I am am looking for a direct implementation.
Did you mean by "direct implementation" setting the qss on the toolbutton? If so, that makes no difference and also there you have to respect the css syntax:

tb->setStyleSheet ("::down-arrow {subcontrol-position: right center}");

qtpizarro
22nd August 2015, 19:37
Si necesitas estilizar y/o quieres controlar la flecha hacia abajo de los botones QToolButton de un QToolBar, es posible que tengas problemas cuando los creas a partir de QAction. La manera de acceder a ello es utilizando QToolButton::menu-arrow {...} o QToolButton::menu-button {...}

Si tu tienes una barra de navegación la puedes nombrar barra->setObjectName("miBarra");
Y puedes controlar su flecha abajo con #miBarra QToolButton::menu-arrow {...} o #miBarra QToolButton::menu-button {...}