JeffB
JeffB

Reputation: 11

QToolButtons Not-Flat Button Style

I am using Qt Widgets version 4.8. I am placing QAction objects into a QToolBar. I am displaying text only, no icons. The text appears flat with no outline, until one hovers over the text, and then the text appears as a button. I would prefer to have that button look all the time, and not just on hover.

I recognize that the flat look seems standard everywhere, but it is always used with icons. I also recognize that the background shading of the QToolBar makes it apparent that it is a toolbar and therefore contains actions. However, to everyone that I have shown the application to, it is not apparent to them that there are actions there at all, and I have had management ask me to make it look like a button all the time.

I have Qt configured to use the CleanLooks style. Unfortunately, this does not appear to be defined by a style sheet that I can modify. If I try to set a style for a QToolButton, this style erases the original style, instead of just updating a single item. I would need to know all the original values to do this properly.

Any answers or suggestions?

Upvotes: 1

Views: 1413

Answers (2)

Romário
Romário

Reputation: 1966

Use QToolBar::widgetForAction. For example:

auto toolButton =
    static_cast<QToolButton *>(toolBar->widgetForAction(action));

toolButton->setAutoRaise(false);

From my own answer to a similar question: https://stackoverflow.com/a/31972514/2507567

Upvotes: 1

Amartel
Amartel

Reputation: 4286

You could use QAction * QToolBar::addWidget ( QWidget * widget ) method to add an actual button on your toolbar.

Upvotes: 1

Related Questions