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. QMenu / submenu issues...how to add QAction?
Forum Updated to NodeBB v4.3 + New Features

QMenu / submenu issues...how to add QAction?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 609 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 last edited by Anonymous_Banned275
    #1

    I am still not sure how menu and its action relates.

    I am adding a new menu into existing
    , build by QtDesigner , menu.

    Thanks to this forum help I can add checked box to submenu attached to the added menu.

    I like to add "...->setCheckable(true); to the main , added , menu.
    ( I will tackle adding check boxes to QDesigner menus later.)

    But I do not know how to add "action" to newly added QMenu - I am adding "just" menu - no action.

       QAction *qAction = m_ui->menuWindow_cpntrol->addAction( "Add TEST submenu" );
        //. QMenu* submenuTEST =m_ui->menuWindow_cpntrol->addMenu( "Add TEST memu" );
        //submenuTEST->setCheckable(true);
        QAction* actionTEST_Setup[3]; // = submenuTEST->addAction( "Add TEST submenu" );
    
    
        for ( int index = 0; index < 3 ; index++)
        {
            text = "Add TEST submenu";
            text += "  index ";
            text += QString::number(index);
            actionTEST_Setup[index] = submenuTEST->addAction( text );
            actionTEST_Setup[index]->setCheckable(true);
         }
    
    
    
    Pl45m4P 1 Reply Last reply
    0
    • A Anonymous_Banned275

      I am still not sure how menu and its action relates.

      I am adding a new menu into existing
      , build by QtDesigner , menu.

      Thanks to this forum help I can add checked box to submenu attached to the added menu.

      I like to add "...->setCheckable(true); to the main , added , menu.
      ( I will tackle adding check boxes to QDesigner menus later.)

      But I do not know how to add "action" to newly added QMenu - I am adding "just" menu - no action.

         QAction *qAction = m_ui->menuWindow_cpntrol->addAction( "Add TEST submenu" );
          //. QMenu* submenuTEST =m_ui->menuWindow_cpntrol->addMenu( "Add TEST memu" );
          //submenuTEST->setCheckable(true);
          QAction* actionTEST_Setup[3]; // = submenuTEST->addAction( "Add TEST submenu" );
      
      
          for ( int index = 0; index < 3 ; index++)
          {
              text = "Add TEST submenu";
              text += "  index ";
              text += QString::number(index);
              actionTEST_Setup[index] = submenuTEST->addAction( text );
              actionTEST_Setup[index]->setCheckable(true);
           }
      
      
      
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @AnneRanch said in QMenu / submenu issues...how to add QAction?:

      I like to add "...->setCheckable(true); to the main , added , menu.
      ( I will tackle adding check boxes to QDesigner menus later.)

      There is no need for this. The checkbox appear automatically when you enable checkable.

      But I do not know how to add "action" to newly added QMenu - I am adding "just" menu - no action.

      Isn't this what you are doing here?!:

      actionTEST_Setup[index] = submenuTEST->addAction( text );
      

      You have your menu (the one created in designer) and your new submenuTEST.
      After you add your QActions to your new menu and add this submenuTEST to your existing menu with addMenu

      If you add actions to a menu and add this menu to another menu, they are all connected

      • https://doc.qt.io/qt-6/qmenu.html#addMenu-1

      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
      1
      • Pl45m4P Pl45m4

        @AnneRanch said in QMenu / submenu issues...how to add QAction?:

        I like to add "...->setCheckable(true); to the main , added , menu.
        ( I will tackle adding check boxes to QDesigner menus later.)

        There is no need for this. The checkbox appear automatically when you enable checkable.

        But I do not know how to add "action" to newly added QMenu - I am adding "just" menu - no action.

        Isn't this what you are doing here?!:

        actionTEST_Setup[index] = submenuTEST->addAction( text );
        

        You have your menu (the one created in designer) and your new submenuTEST.
        After you add your QActions to your new menu and add this submenuTEST to your existing menu with addMenu

        If you add actions to a menu and add this menu to another menu, they are all connected

        • https://doc.qt.io/qt-6/qmenu.html#addMenu-1
        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        @Pl45m4 I just fished the task adding menu and submenu. I could post the code , but it is still "under construction".
        My main misunderstanding was the relation between menu and action.

        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