Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QToolbar resizing



  • Hi all,

    I have own implementation of docking window subsystem and main window, use QMainWindow as main window of application was rejected. But using QToolbar as well.

    Then I noticed when I try to resize to minimum main window (parent for my toolbar), there was appeared ">>" button on the right side of toolbar, but when I've tried click was nothing happened.

    What's wrong? Seems to me that part of code implements in QMainWindow? Where that handled? Please point me to peace of source code of Qt.

    Thanks a lot,
    Alex



  • @Alexey-Serebryakov

    Apparently it's called extension button

    When a toolbar is resized in such a way that it is too small to
    
    show all the items it contains, an extension button will appear as
    
    the last item in the toolbar. Pressing the extension button will
    
    pop up a menu containing the items that do not currently fit in
    
    the toolbar.
    

    Check line 409 from: https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qtoolbar.cpp.html#409

    If you read further:

    When a QToolBar is not a child of a QMainWindow, it loses the ability
    
    to populate the extension pop up with widgets added to the toolbar using
    
    addWidget(). Please use widget actions created by inheriting QWidgetAction
    
    and implementing QWidgetAction::createWidget() instead.
    

    So this is the case here :) Because as you've said, you don't have a QMainWindow based "main" window. But you could try what they suggest (QWidgetActions + createWidget())



  • @Alexey-Serebryakov said in Toolbar:

    QMainWindow as main window of application was rejected

    Rejected by whom?

    Then I noticed when I try to resize to minimum main window (parent for my toolbar), there was appeared ">>" button on the right side of toolbar, but when I've tried click was nothing happened.

    Do you actually use your toolBar? Do you have items / actions in it?

    If I'm not mistaken this is to expand or show (and use) your items in your toolBar even when the toolBar is too small to show all its items.

    QToolbarButtons.png

    Please point me to peace of source code of Qt.

    Have a look yourself :)
    Haven't found it yet.
    It could also come from your OS (I dont know if it is a Qt thing).

    ToolBar

    MainWindow



  • @Pl45m4

    We've decided to use own implementation of main window of application, not QMainWindow.

    Sure, we use QToolbar with actions/items. And when I resized main window too small toolbar resized too, some items disappeared and appeared ">>" button.

    13fa48c3-dcdd-41a3-8469-8bab3115bf64-image.png

    But when I clicked then nothing happened. I'm not suer that it OS-platform specific, this is Qt feature. I wish to find where that handled in Qt source code.



  • @Alexey-Serebryakov

    Apparently it's called extension button

    When a toolbar is resized in such a way that it is too small to
    
    show all the items it contains, an extension button will appear as
    
    the last item in the toolbar. Pressing the extension button will
    
    pop up a menu containing the items that do not currently fit in
    
    the toolbar.
    

    Check line 409 from: https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qtoolbar.cpp.html#409

    If you read further:

    When a QToolBar is not a child of a QMainWindow, it loses the ability
    
    to populate the extension pop up with widgets added to the toolbar using
    
    addWidget(). Please use widget actions created by inheriting QWidgetAction
    
    and implementing QWidgetAction::createWidget() instead.
    

    So this is the case here :) Because as you've said, you don't have a QMainWindow based "main" window. But you could try what they suggest (QWidgetActions + createWidget())


Log in to reply