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. How to add "checkable" to QMenu - using C++ code ?
Forum Updated to NodeBB v4.3 + New Features

How to add "checkable" to QMenu - using C++ code ?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 367 Views 3 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on 10 Jan 2024, 16:39 last edited by
    #1

    I have looked at several examples and still have no clear no idea how to add checkable widget - preferred simple "checkbox"- to the menu.
    My primary problem is how to specify "checkbox" to be used..

     QMenu *TEST = subMenu[index]->addMenu(" subsub TEST menu " + i );
    
    P 1 Reply Last reply 10 Jan 2024, 16:54
    0
    • A Anonymous_Banned275
      10 Jan 2024, 16:39

      I have looked at several examples and still have no clear no idea how to add checkable widget - preferred simple "checkbox"- to the menu.
      My primary problem is how to specify "checkbox" to be used..

       QMenu *TEST = subMenu[index]->addMenu(" subsub TEST menu " + i );
      
      P Offline
      P Offline
      Pl45m4
      wrote on 10 Jan 2024, 16:54 last edited by Pl45m4 1 Oct 2024, 16:55
      #2

      @AnneRanch

      You can make an Action in a QMenu checkable with

      action->setCheckable(true);

      • https://doc.qt.io/qt-6/qaction.html#checkable-prop

      toggled(true/false) is the signal to connect and react when action is checked/unchecked

      • https://doc.qt.io/qt-6/qaction.html#toggled

      or check it yourself with:

      isChecked()


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      A 1 Reply Last reply 10 Jan 2024, 18:49
      2
      • P Pl45m4
        10 Jan 2024, 16:54

        @AnneRanch

        You can make an Action in a QMenu checkable with

        action->setCheckable(true);

        • https://doc.qt.io/qt-6/qaction.html#checkable-prop

        toggled(true/false) is the signal to connect and react when action is checked/unchecked

        • https://doc.qt.io/qt-6/qaction.html#toggled

        or check it yourself with:

        isChecked()

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on 10 Jan 2024, 18:49 last edited by
        #3

        @Pl45m4 Thanks, it is so stupidly simple...
        I do not get why the examples are so complicated...
        Oh well - one problem solved
        Many thanks.

        1 Reply Last reply
        0
        • A Anonymous_Banned275 has marked this topic as solved on 10 Jan 2024, 18:49

        1/3

        10 Jan 2024, 16:39

        • Login

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