Skip to content
  • 0 Votes
    2 Posts
    131 Views
    C

    @Matcha2024 Welcome to the Qt Forums.

    What your unspecified operating system does when you right-click on its desktop is down to that operating system. What that has to do with an unspecified version of Qt Creator, installed in an unspecified way, is not clear.

    I am only guessing at your problem because the description is so poor.

  • 0 Votes
    3 Posts
    247 Views
    JonBJ

    @BigBen
    When you go QMenu::addAction("SomeString") it creates a QAction for you, and returns it. And QMenu::exec() returns the QAction which was clicked. So you could check which one is returned and act on it, like:

    QAction *hideAction = myMenu.addAction("Hide"); QAction *showAction = myMenu.addAction("Show"); QAction* selectedAction = myMenu.exec(globalPos); if (selectedAction == hideAction) qInfo() << "Hide"; else if (selectedAction == showAction) qInfo() << "Show";

    Alternatively, when you create the QActions you could attach a slot to its triggered signal:

    connect(hideAction, &QAction::triggered, this, []() { qInfo() << "Hide"; } );
  • 0 Votes
    15 Posts
    6k Views
    L

    Solved it by creating a derivative of the CustomQPushButton class definition! Thanks!

  • 0 Votes
    5 Posts
    6k Views
    jsulmJ

    @legitnameyo This is not how it works. You will need to subclass QPushButton and override http://doc.qt.io/qt-5/qwidget.html#mousePressEvent
    You can find an example here: http://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html

  • 0 Votes
    2 Posts
    1k Views
    D

    @m_jero I don't know why nobody answers this question. Maybe because you didn't supply any code snippets as recommended. Anyway, I suppose you used the exec() function to show the qmenu. Try to use popup() instead and see if it works.

  • 0 Votes
    8 Posts
    2k Views
    K

    Alright, really strange, but just pulled mouse out tried touch pad. Guess what, just acted normal, put mouse back in no problem either. Pulled the mouse out earlier but didn't work then, don't know what changed but the problem is solved. (By the way, it was a cheap mouse with only 4 buttons :))

    Thanks to both of you for your help and fast response.