Juliette Marquis
Juliette Marquis

Reputation: 199

How to customize QToolBar extension button

I am trying to custom a QToolBar. I managed to custom the buttons of my toolbar, but I can't find a way to set the expansion button to the two default arrows...

Here is an illustration to help you understand : enter image description here

On this toolbar, you can see a double arrow at the end of the second toolbar but none at the end of the first tool bar (after Variable)... I would like to set the qt_toolbar_ext_button to the image at this path :/images/images/extension-arrows.png.

The code I used to custom them is :

m_toolbar1->setStyleSheet(
    "QToolBar {border-bottom: 1px solid #808d97;"
    "border-top: 1px solid #808d97; background-color: #3a4f5e;} "

    "QToolButton {background:#3a4f5e; border: 1px solid #585858;"
    "border-style: outset; border-radius: 4px; min-width: 5em; min-height: 1.5em; color: white}"

    "QToolButton:hover {background: #5d7180; border: 1px groove #293843;}"

    "QToolButton:pressed {background:#475864; border: 1px groove #293843;}"
    "QToolButton#qt_toolbar_ext_button {"
        "border: none;"
        "background: url(:/images/images/extension-arrows.png);"
        "padding-top: 20;"
        "width: 20px;"
        "font: bold 14px;"
        "color: red;}");

m_toolbar2->setStyleSheet("background-color: #3a4f5e; color:white;");

This code was inspired by : How to set the QToolButton's icons using style sheet?

Upvotes: 3

Views: 1688

Answers (1)

magrif
magrif

Reputation: 480

I've found this solution, but using API of widgets.

ui->toolBar->findChild<QToolButton*>("qt_toolbar_ext_button")->setIcon(QIcon(":/icon/myico.png")); 

Upvotes: 3

Related Questions