Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. QMenu . QAction how can I add "checked "?
Forum Updated to NodeBB v4.3 + New Features

QMenu . QAction how can I add "checked "?

Scheduled Pinned Locked Moved Unsolved C++ Gurus
7 Posts 2 Posters 952 Views 2 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 14 Jan 2024, 02:05 last edited by
    #1
    This post is deleted!
    A 1 Reply Last reply 14 Jan 2024, 08:25
    0
    • A Anonymous_Banned275
      14 Jan 2024, 02:05

      This post is deleted!

      A Offline
      A Offline
      Axel Spoerl
      Moderators
      wrote on 14 Jan 2024, 08:25 last edited by
      #2

      @AnneRanch
      A menu can't be made checkable, but an action can.
      This alters your code to make the first action you add checkable.

      subMenu[ index_main] = m_ui->menuWindow_cpntrol->addMenu("DEBUG " + list[ index_main] + " #" + QString::number( index_main));
      
      QAction *checkableAction = subMenu[index_main]->addAction("Test checkable action");
      checkableAction->setCheckable(true); // makes it checkable, unchecked by default.
      checkableAction->setChecked(true); // makes it checked
      
              //subMenu[ index_main]->checkable(true);
              subMenu[ index_main]->setVisible(true);
              //subMenu[ index_main]->setCheckable(true);
      

      Software Engineer
      The Qt Company, Oslo

      1 Reply Last reply
      1
      • J JonB referenced this topic on 14 Jan 2024, 16:45
      • A Offline
        A Offline
        Anonymous_Banned275
        wrote on 14 Jan 2024, 16:56 last edited by
        #3
        This post is deleted!
        A 1 Reply Last reply 14 Jan 2024, 17:08
        0
        • A Anonymous_Banned275
          14 Jan 2024, 16:56

          This post is deleted!

          A Offline
          A Offline
          Axel Spoerl
          Moderators
          wrote on 14 Jan 2024, 17:08 last edited by
          #4

          @AnneRanch
          I used the provided code.
          It shows the mechanism of making an action checkable and changing the checked property.
          That works with any action, no matter where in the menu tree it is located.
          You can use it in the main menu just as well.
          Or you can post the code that creates the main menu.

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Anonymous_Banned275
            wrote on 14 Jan 2024, 18:24 last edited by
            #5
            This post is deleted!
            A 1 Reply Last reply 14 Jan 2024, 18:44
            0
            • A Anonymous_Banned275
              14 Jan 2024, 18:24

              This post is deleted!

              A Offline
              A Offline
              Axel Spoerl
              Moderators
              wrote on 14 Jan 2024, 18:44 last edited by
              #6

              @AnneRanch
              Could you post all the code responsible for creating menus and submenus? I am getting lost, because I don’t see the big picture. Could you also sketch the desired menu structure, including checkboxes on actions?

              Software Engineer
              The Qt Company, Oslo

              A 1 Reply Last reply 14 Jan 2024, 20:04
              0
              • A Axel Spoerl
                14 Jan 2024, 18:44

                @AnneRanch
                Could you post all the code responsible for creating menus and submenus? I am getting lost, because I don’t see the big picture. Could you also sketch the desired menu structure, including checkboxes on actions?

                A Offline
                A Offline
                Anonymous_Banned275
                wrote on 14 Jan 2024, 20:04 last edited by
                #7

                FINALLY...

                here a current WORKING as expected - both menu and submenu have check boxes and only main menu has "arrows"....

                Unless there are objections I am going to clean up the worthless code...

                Thanks foe sticking with the problem...

                        mainAction[index_main] = m_ui->menuWindow_cpntrol->addAction(list[ index_main] + " #" + QString::number( index_main));
                        mainAction[index_main]->setCheckable(true);
                        //adds arrows
                        mainAction[index_main]->setMenu(tempmenu);
                        subAction[index_main] = tempmenu->addAction(list_hcitool[ index_main] + " #" + QString::number( index_main));
                        subAction[index_main]->setCheckable(true);
                
                1 Reply Last reply
                0

                1/7

                14 Jan 2024, 02:05

                • Login

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