Important: Please read the Qt Code of Conduct -

How should I learn about context menu's? Any good resources? / Object specific context menu

  • Hi,

    I want to learn about context menu. Is there any good resource or course that covers it?
    Can you have context menu's for specific items in the applications? Let's say, for a QLabel, or for a QTextTabel inside a QTextEdit?

    Appreciate the help. :)

  • Lifetime Qt Champion


    Take a look at the Menus Example.

    It is explained for the QMainWindow class but it's also valid for others as explained at the bottom of the page.

  • @SGaist

    I kinda get stuck on the "whats the difference between contextMenuEvent() and setContextMenuPolicy()" stuff and on the fact that when i put down this code in my own project:

        void contextMenuEvent(QContextMenuEvent *event) override;
    #endif // QT_NO_CONTEXTMENU

    I get this error:

    0_1563749510348_Screenshot 2019-07-22 at 00.51.34.png

    What's up with this?

  • @bartvrossum

    Exactly what is written there...

    If you redefine a function, you have to mark it as "override".

    Put the override behind your function header and the warning is gone (in your case: destructor)

Log in to reply