Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWidgetAction & QToolBar - no actionTriggered signal...
QtWS25 Last Chance

QWidgetAction & QToolBar - no actionTriggered signal...

Scheduled Pinned Locked Moved Unsolved General and Desktop
qwidgetactionqtoolbar
5 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dariusz
    wrote on 3 Jul 2019, 02:50 last edited by Dariusz 7 Mar 2019, 05:07
    #1

    Hey

    When I create QLineEdit as my QWidget action by subclassing QWidgetAction and connect :

        connect(mEditor, &QLineEdit::editingFinished, this, &QWidgetAction::trigger);
        connect(mEditor, &QLineEdit::textChanged, this, &QWidgetAction::trigger);
    
    

    When I go to my toolbar and change the text my toolbar does not get triggered with new text...

    How can I connect them? I should be getting toolbar::actionTriggered signal if I'm not wrong ?

    I add my action in this way >

    toolbar->addAction(static_cast<testWidgetAction *>(obj));
    

    TIA

    J 1 Reply Last reply 3 Jul 2019, 04:32
    0
    • D Dariusz
      3 Jul 2019, 02:50

      Hey

      When I create QLineEdit as my QWidget action by subclassing QWidgetAction and connect :

          connect(mEditor, &QLineEdit::editingFinished, this, &QWidgetAction::trigger);
          connect(mEditor, &QLineEdit::textChanged, this, &QWidgetAction::trigger);
      
      

      When I go to my toolbar and change the text my toolbar does not get triggered with new text...

      How can I connect them? I should be getting toolbar::actionTriggered signal if I'm not wrong ?

      I add my action in this way >

      toolbar->addAction(static_cast<testWidgetAction *>(obj));
      

      TIA

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 3 Jul 2019, 04:32 last edited by
      #2

      @Dariusz said in QActionWidget & QToolBar - no actionTriggered signal...:

      toolbar->addAction(static_cast<testWidgetAction *>(obj));

      What is obj here? If it is already an instance of testWidgetAction why do you cast it? What is testWidgetAction?
      Also I don't see any addAction() overloads in QToolBar which take an action pointer as its first parameter.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 1 Reply Last reply 3 Jul 2019, 04:46
      0
      • J jsulm
        3 Jul 2019, 04:32

        @Dariusz said in QActionWidget & QToolBar - no actionTriggered signal...:

        toolbar->addAction(static_cast<testWidgetAction *>(obj));

        What is obj here? If it is already an instance of testWidgetAction why do you cast it? What is testWidgetAction?
        Also I don't see any addAction() overloads in QToolBar which take an action pointer as its first parameter.

        D Offline
        D Offline
        Dariusz
        wrote on 3 Jul 2019, 04:46 last edited by
        #3

        @jsulm Hey addAction() comes from QWidget that is being inherited by QToolbar, it calls createWidget() by itself and handles that. I though that qtoolbar has its own signal connection system that would connect to QWidgetAction automatically. Or that QWidget Would do this.

        Esentially
        QToolBar->addAction(new QWidgetAction()) does not automatically connect to toolbar as I though it would.

        J 1 Reply Last reply 3 Jul 2019, 04:50
        0
        • D Dariusz
          3 Jul 2019, 04:46

          @jsulm Hey addAction() comes from QWidget that is being inherited by QToolbar, it calls createWidget() by itself and handles that. I though that qtoolbar has its own signal connection system that would connect to QWidgetAction automatically. Or that QWidget Would do this.

          Esentially
          QToolBar->addAction(new QWidgetAction()) does not automatically connect to toolbar as I though it would.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 3 Jul 2019, 04:50 last edited by
          #4

          @Dariusz Maybe I'm blind but I can't find an addAction() overload with a QAction parameter. All I can see is:

          addAction(const QString &) : QAction *
          addAction(const QIcon &, const QString &) : QAction *
          addAction(const QString &, const QObject *, const char *) : QAction *
          addAction(const QIcon &, const QString &, const QObject *, const char *) : QAction *
          addAction(const QString &, Functor ) : QAction *
          addAction(const QString &, const QObject *, Functor ) : QAction *
          addAction(const QIcon &, const QString &, Functor ) : QAction *
          addAction(const QIcon &, const QString &, const QObject *, Functor ) : QAction *
          addActions(QList<QAction *> )
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          D 1 Reply Last reply 3 Jul 2019, 05:01
          0
          • J jsulm
            3 Jul 2019, 04:50

            @Dariusz Maybe I'm blind but I can't find an addAction() overload with a QAction parameter. All I can see is:

            addAction(const QString &) : QAction *
            addAction(const QIcon &, const QString &) : QAction *
            addAction(const QString &, const QObject *, const char *) : QAction *
            addAction(const QIcon &, const QString &, const QObject *, const char *) : QAction *
            addAction(const QString &, Functor ) : QAction *
            addAction(const QString &, const QObject *, Functor ) : QAction *
            addAction(const QIcon &, const QString &, Functor ) : QAction *
            addAction(const QIcon &, const QString &, const QObject *, Functor ) : QAction *
            addActions(QList<QAction *> )
            
            D Offline
            D Offline
            Dariusz
            wrote on 3 Jul 2019, 05:01 last edited by Dariusz 7 Mar 2019, 05:07
            #5

            @jsulm said in QActionWidget & QToolBar - no actionTriggered signal...:

            @Dariusz Maybe I'm blind but I can't find an addAction() overload with a QAction parameter. All I can see is:

            addAction(const QString &) : QAction *
            addAction(const QIcon &, const QString &) : QAction *
            addAction(const QString &, const QObject *, const char *) : QAction *
            addAction(const QIcon &, const QString &, const QObject *, const char *) : QAction *
            addAction(const QString &, Functor ) : QAction *
            addAction(const QString &, const QObject *, Functor ) : QAction *
            addAction(const QIcon &, const QString &, Functor ) : QAction *
            addAction(const QIcon &, const QString &, const QObject *, Functor ) : QAction *
            addActions(QList<QAction *> )
            

            https://code.woboq.org/qt5/qtbase/src/widgets/kernel/qwidget.cpp.html#_ZN7QWidget9addActionEP7QAction (press enter 2x in search input www as for some reason it does not scroll to right spot)

            Edit I just noticed I messed up title... corrected to QWidgetAction sorry!

            1 Reply Last reply
            0

            2/5

            3 Jul 2019, 04:32

            • Login

            • Login or register to search.
            2 out of 5
            • First post
              2/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved