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

QWidgetAction - what does QToolbar do to it ?



  • Hey

    Does QToolbar deletes its QWidgetActions / recreate them on each drag/drop/ reordering of actions ? I keep hitting memorry errors on my custom widgets while in toolbar and I'm trying to debug why... Only thing comes to my mind is that qtoolbar is deleting/recreating them...


  • Lifetime Qt Champion

    Since it's your own widget - why not simply adding debug output or breakpoints to your dtors and see if you're right?



  • Well I can see QToolbar deleting my actions when I perform drag on toolbar to place it in another location. But it never recreates them again ? I'm at loss :- ( I'm trying to figure out where the error is and for that I need to understand the toolbar/action system better...

    As far as I can tell, when action is "hidden" when toolbar is to short to display all actions. On initial creation I can press arrow and see missing actions. But when I drag&drop. Every hidden action gets deleted and never re-created again...

    and I removed deleteWidget overload and it stopped deleting the actions...sigh...



  • @Nope I cant get it to work.

    if I run this

    void testAction::deleteWidget(QWidget *widget) {
        qInfo() << "icWALineDouble DELETE";
        mParent->deleteLater();
        mParent = nullptr;
    }
    

    or this

    void testAction::deleteWidget(QWidget *widget) {
       QWidgetAction::deleteWidget(widget);
    }
    

    And I perform re-arrangement of toolbar - move it left/right & any of actions were hidden. They get deleted but they never recover back when I dragg teh toolbar back in.

    Is this a bug or something?

    Why would toolbar not recreate actions it had before re-arrangement of itself?


  • Lifetime Qt Champion

    We can only guess so please provide a minimal, compilable testcase for your issue.


Log in to reply