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. Add external signal on QAction
Qt 6.11 is out! See what's new in the release blog

Add external signal on QAction

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.4k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    Peggy
    wrote on last edited by
    #1

    Hello,

    is there some possibility to add new signal to the QAction? With QPushButton you can do it easily but QAction does not know any signals except the pre defined signals.

    1 Reply Last reply
    0
    • ZlatomirZ Offline
      ZlatomirZ Offline
      Zlatomir
      wrote on last edited by
      #2

      Tell us more about what are you trying to achieve.

      Anyway generic answers are: you can derive from QAction class and add the functionality you need, but first look at the "signals that are already there":http://doc.qt.digia.com/qt/qaction.html#signals - maybe what you need is already there.

      Also you can connect signal to signal - so triggered signal can trigger one of your signals.

      https://forum.qt.io/category/41/romanian

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Peggy
        wrote on last edited by
        #3

        By clicking on open icon on the toolbar I want to call another class, which is done in the slot.
        @
        QAction* openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
        openAct->setShortcuts(QKeySequence::Open);
        openAct->setStatusTip(tr(" an existing file"));
        connect(openAct, SIGNAL(setName(QString)), this, SLOT(callTheClass(QString)));
        @

        The problem is the signal: setName(QString) is not accepted by QAction

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          This doesn't make a lot of sense. The QAction indeed doesn't have a setName(QString) signal, but also it has no way to know what the name should be.

          However, I guess what you could do, is create a QAction-derived class that shows a file open dialog that allows you to select a file, and then emit a signal with the selected file name. However, I think this is the wrong place to put this functionality.

          1 Reply Last reply
          0

          • Login

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