QDockWidget resize handle style not working.



  • It is probably common Qt fail, but i can't find the solution.

    I have QMainWindow which should have typical IDE like GUI (header with fixed height (buttons etc.), left resizable dockable sidebar (project files etc.), right resizable dockable sidebar (AST view, properties, etc.), bottom resizable dockable sidebar (compiler output etc).

    So i decided to use QDockWidget, which is what i need except that the header shouldn't be resizable at all. This is not a problem, you can setup QSizePolicy::Fixed for Header height.

    The problem is when using stylesheets, because if the header is not resizable, the space for separator (eg. resize handle) is still reserved but the seperator itself is not painted (which is logical if the size of header is fixed and you can't resize it, BUT THAN THE SPACE FOR SEPARATOR SHOULDNT BE RESERVED). This leads to behavior where your style is not applied to the space for separator and you see some background color of underlying window.

    Here you can see the condition which says the separator is not painted.
    https://github.com/qtproject/qtbase/blob/dev/src/widgets/widgets/qdockarealayout.cpp#L1644

    I need the separator to be painted because it acts for me even as border.


  • Moderators

    I'm not sure I understand. What do you mean by a "header"? Which class is that? Usually the buttons are placed on a toolbar (QToolBar) which can be made movable or stationary.



  • @Chris-Kawa The header will be QFrame subclass with custom content probably. I don't want to use QToolBar because i have feel that it is very limited to just put some buttons in single row. Because the header should be from corner to corner, i can't add it as child of centralWidget if using DockWidgets on sides. So i need to add the Header via QDockWIdget in top area and set the fixed policy for height. But than that weird behavior appears.

    I will probably make some changes in Qt code, compile it and use that my version for my app, because it is impossible to do what i need (it is actually weird because the IDE like GUI is very common).

    The first two "rows" of this GUI looks similar to header i want.
    http://twofuckingdevelopers.com/wp-content/uploads/tswsmac_02.png


  • Moderators

    Instead of modifying Qt you can put QMainWindow in a vertical layout in another widget. This way you could place whatever you want above the QMainWindow.



  • @Chris-Kawa That is good idea, thanks. But i need even that QMenuBar funcionality from QMainWindow. The menu should be drawn before that hypothehic vertical layout (so not be part of QMainWindow in that case).


  • Moderators

    QLayout has a setMenuBar method. Despite the misleading name it can use any QWidget, including a toolbar or menu bar or another widget with both in another vertical layout. It's pretty flexible. A setup similar to that on the picture you posted looks easy to do this way.

    Another way is to use a main window which would handle menu bars and toolbars and then place a widget with vertical layout as a central widget. Inside that layout you would have a custom widget for that breadcrumb thingie from the picture and a main window under it to handle docks and main content.



  • @Chris-Kawa Yes it sounds good, i will try it. Didn't though that way the QMainWindow can be actually used inside another widget.


  • Moderators

    QMainWindow is just a QWidget like any other. The biggest difference is that it has a private layout customized for docking functionality. I think the reason most don't tend to realize this is because of the misleading name which suggests it should be the top level widget, which it doesn't have to be.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.