Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. menu name changing
QtWS25 Last Chance

menu name changing

Scheduled Pinned Locked Moved Solved Mobile and Embedded
12 Posts 4 Posters 1.7k Views
  • 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
    ali1377
    wrote on last edited by ali1377
    #1

    how can I define menu which name change with selecting its sub Menu;

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What is the purpose of a menu that changes its own name ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What is the purpose of a menu that changes its own name ?

        A Offline
        A Offline
        ali1377
        wrote on last edited by
        #3

        @sgaist Hi
        I wanna to implemente like this picture 0_1567615288228_Capture.PNG

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          Hi
          Its not the menu name, but the text it shows you want to change?

          So when user selects the 5V or 2V the menu comes and
          when user select 1-50V then the 5v or 2V it then changes to the
          value selected ?

          If that is the case, why not use a QQComboBox as it works exactly like that.

          If you really want to use QMenu, then you will have to keep pointer around for the
          5V/2V and then when you select a new menu, replace its text to the selected one's text.

          A 1 Reply Last reply
          1
          • mrjjM mrjj

            Hi
            Its not the menu name, but the text it shows you want to change?

            So when user selects the 5V or 2V the menu comes and
            when user select 1-50V then the 5v or 2V it then changes to the
            value selected ?

            If that is the case, why not use a QQComboBox as it works exactly like that.

            If you really want to use QMenu, then you will have to keep pointer around for the
            5V/2V and then when you select a new menu, replace its text to the selected one's text.

            A Offline
            A Offline
            ali1377
            wrote on last edited by
            #5

            @mrjj Hi
            thanks. but can we locate qqcombo near in menu bar?
            0_1567622504960_Capture.PNG in fact I wanna to bring this near the menu bar .how can I do this?

            mrjjM 1 Reply Last reply
            0
            • A ali1377

              @mrjj Hi
              thanks. but can we locate qqcombo near in menu bar?
              0_1567622504960_Capture.PNG in fact I wanna to bring this near the menu bar .how can I do this?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @ali1377
              Hi
              You can use
              https://doc.qt.io/qt-5/qwidgetaction.html
              like here
              https://stackoverflow.com/questions/8358965/is-there-a-way-to-add-a-qwidget-to-a-qmenu-in-qtcreator

              1 Reply Last reply
              1
              • A Offline
                A Offline
                ali1377
                wrote on last edited by
                #7

                thanks . excuse me but can I put a bottom on black ribbon.0_1567629723340_Capture.PNG

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi
                  I dont know what that type of QWidget that "black ribbon" is.

                  A 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    Hi
                    I dont know what that type of QWidget that "black ribbon" is.

                    A Offline
                    A Offline
                    ali1377
                    wrote on last edited by
                    #9

                    @mrjj
                    Hi
                    thank you.
                    I couldnt make a menu up to now.
                    whats wrong?
                    QMenuBar* bar = new QMenuBar(this);

                                 QMenu* menu1 = new QMenu("First menu");
                         
                                 bar->addMenu(menu1);
                         
                         
                         
                                 QString str=":analog.png";
                         
                                 QPixmap pixmap(str);
                         
                                 QIcon ButtonIcon(pixmap);
                         
                                 menu1->setIcon(ButtonIcon);
                         
                         
                         
                         
                         
                                    QPalette qpalette = palette();
                         
                    
                         
                                 qpalette.setColor(QPalette::Background, Qt::black);
                         
                    
                         
                                 bar->addMenu(menu1);
                         
                                 ui->horizontalLayout_38->addWidget(bar);
                         
                                 ui->horizontalLayout_38->addWidget(menu1);
                         
                                 menu1->setTitle(QString("Menu"));
                         
                         
                         
                                 QPalette q1palette = palette();
                         
                                 q1palette.setColor(QPalette::Background, Qt::blue);
                         
                                 bar->setPalette(q1palette);
                         
                                 QMenu* trigger = new QMenu("Trigger");
                         
                                 QMenu* measure = new QMenu("Measure");
                         
                         
                         
                         
                         
                                 QAction maximum("actionMaximum",this);
                         
                                 measure->addAction(&maximum);
                         
                                 connect(&maximum,SIGNAL(triggerd()),this,SLOT(on_actionMaximum_triggered()));
                         
                                 QAction minimum("actionMinimum",this);
                         
                                 measure->addAction(&minimum);
                         
                                 connect(&minimum,SIGNAL(triggerd()),this,SLOT(on_actionMinimum_triggered()));
                         
                                 QAction peakToPeak("actionPeakToPeak",this);
                         
                                 measure->addAction(&peakToPeak);
                         
                                 connect(&peakToPeak,SIGNAL(triggerd()),this,SLOT(on_actionPeakToPeak_triggered()));
                         
                                 QAction frequency("actionFrequency",this);
                         
                                 measure->addAction(&frequency);
                         
                                 connect(&frequency,SIGNAL(triggerd()),this,SLOT(on_actionFrequency_triggered()));
                         
                                 QAction averege("actionAverege",this);
                         
                                 measure->addAction(&averege);
                         
                                 connect(&averege,SIGNAL(triggerd()),this,SLOT(on_actionAverege_triggered()));
                         
                                 QAction rms("actionRMS",this);
                         
                                 measure->addAction(&rms);
                         
                                 connect(&rms,SIGNAL(triggerd()),this,SLOT(on_actionRMS_triggered()));
                         
                                 ////////////////////////
                         
                                 QMenu* mode = new QMenu("Mode");
                         
                                 menu1->addMenu(measure);
                         
                                 QAction actionAuto("Auto_TriggerMenu",this);
                         
                                 mode->addAction(&actionAuto);
                         
                                 connect(&actionAuto, SIGNAL(triggered()), this, SLOT(on_actionAuto_triggerd()));
                         
                                 QAction actionNormal("Normal_TriggerMenu",this);
                         
                                 mode->addAction(&actionNormal);
                         
                                 connect(&actionNormal, SIGNAL(triggered()), this, SLOT(on_actionNormal_Triggered()));
                         
                                 QAction actionSingle("Single_TriggerMenu",this);
                         
                                 mode->addAction(&actionSingle);
                         
                                 connect(&actionSingle, SIGNAL(triggered()), this, SLOT(on_actionSingle_triggered()));
                         
                                 QMenu* edge = new QMenu("Edge");
                         
                                 QAction actionRising("Rising_TriggerMenu",this);
                         
                                 edge->addAction(&actionRising);
                         
                                 connect(&actionRising, SIGNAL(triggered()), this, SLOT(on_actionRising_triggered()));
                         
                                 QAction actionFalling("Falling_TriggerMenu",this);
                         
                                 edge->addAction(&actionFalling);
                         
                                 connect(&actionFalling, SIGNAL(triggered()), this, SLOT(on_actionFalling_triggerd()));
                         
                         
                         
                                 ///////////////////////////////////////////////////
                         
                                 menu1->addMenu(trigger);
                         
                                 trigger->addMenu(mode);
                         
                                 trigger->addMenu(edge);
                         
                                 menu1->addMenu(measure);
                         
                                 menu1->setAutoFillBackground(true);
                         
                                 menu1->setPalette(qpalette);
                         
                                 trigger->setAutoFillBackground(true);
                         
                                 trigger->setPalette(qpalette);
                         
                                 measure->setAutoFillBackground(true);
                         
                                 measure->setPalette(qpalette);
                         
                                 edge->setAutoFillBackground(true);
                         
                                 edge->setPalette(qpalette);
                         
                                 mode->setAutoFillBackground(true);
                         
                                 mode->setPalette(qpalette);
                    
                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      ali1377
                      wrote on last edited by
                      #10

                      @ali1377 it doesnt make any action to menu(like trigger menu and measure menu) which has been defined in code.

                      A 1 Reply Last reply
                      0
                      • A ali1377

                        @ali1377 it doesnt make any action to menu(like trigger menu and measure menu) which has been defined in code.

                        A Offline
                        A Offline
                        ali1377
                        wrote on last edited by
                        #11

                        @ali1377 .I made menu in ui with default menubar. then add it to pushButton .without any defining in c++ file.
                        it has been solved . thanks all.

                        Pablo J. RoginaP 1 Reply Last reply
                        1
                        • A ali1377

                          @ali1377 .I made menu in ui with default menubar. then add it to pushButton .without any defining in c++ file.
                          it has been solved . thanks all.

                          Pablo J. RoginaP Offline
                          Pablo J. RoginaP Offline
                          Pablo J. Rogina
                          wrote on last edited by
                          #12

                          @ali1377 said in menu name changing:

                          it has been solved

                          so please mark your post as such! Thanks

                          Upvote the answer(s) that helped you solve the issue
                          Use "Topic Tools" button to mark your post as Solved
                          Add screenshots via postimage.org
                          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                          1 Reply Last reply
                          1

                          • Login

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