2

Does anyone have idea on how to style this rectangular button -which is a default child of a QToolbar?

enter image description here enter image description here enter image description here

First two images show the button when the graphical interface is on normal screen mode. It appears; since toolbar icons don't have enough space. Third picture shows fullscreen mode, in which my icons have space.

I want to style its shape, so that it has a radial border, without a corner. This will cancel its ugly look, in second image.

I want to let users use the interface in normal view, so locking application to fullscreen is not an option. I do want to use the button, so removing is not acceptable. Styling its position to 5 pixels left or replacing it with another stylable button could be possible solutions, but I couldn't manage to do them.

I played a lot with toolbutton and pushbutton stylesheets, but had no luck on styling this small button. I am pretty obsessed about my graphical design, but don't want to waste too much time (if solution is not trivial, I will change my toolbar to a rectangular one).

Thanks in advance.

baci
  • 2,528
  • 15
  • 28

3 Answers3

2

I found the solution by listing the children object names of my toolbar.

QStringList list;
for(int i=0; i<toolBar->children()->size(); i++)
list.append(toolBar->children()[i]->objectName();

Inside the list, there is only one object that has a default name (not " "). It is qt_toolbar_ext_button

Then I was able to style it as:

"#qt_toolbar_ext_button { //... }"
baci
  • 2,528
  • 15
  • 28
0

I know this has been answered, but for anyone who needs to know the answer its a "QToolButton" and if you need to style a specific button with an object name you do "QToolButton#objectName" in an external resources file stylesheet or in the Widget UI stylesheet dialog for different objects.

QToolButton#objectName {

}

Check out the documentation - http://doc.qt.digia.com/4.2/stylesheet.html This gives you the syntax for stylesheets in Qt, or "QSS" files.

MozzieJoe
  • 112
  • 12
  • 1
    well, the problem was that i didn't know the object name, since i didnt create it. it is specified by the framework itself: qt_toolbar_ext_button. "How to get object name or selector of QToolButton that on QToolBar?" would be a better question. – baci Apr 09 '15 at 16:25
  • Could you not set object name in the code, can you access this frameworks GUI objects? If you can then I'd suggest setting object name as previously mentioned and then working with it in QSS, if possible! :) – MozzieJoe Apr 10 '15 at 14:51
-1

Just do it: Qt documentation about stylesheets

Dmitry Sazonov
  • 8,801
  • 1
  • 35
  • 61