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
Forum Updated to NodeBB v4.3 + New Features

menu name changing

Scheduled Pinned Locked Moved Solved Mobile and Embedded
12 Posts 4 Posters 1.8k 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
    ali1377
    wrote on 4 Sept 2019, 14:58 last edited by ali1377 9 Nov 2019, 20:58
    #1

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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 4 Sept 2019, 16:38 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 4 Sept 2019, 16:41
      0
      • S SGaist
        4 Sept 2019, 16:38

        Hi,

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

        A Offline
        A Offline
        ali1377
        wrote on 4 Sept 2019, 16:41 last edited by
        #3

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

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 4 Sept 2019, 18:03 last edited by mrjj 9 Apr 2019, 18:03
          #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 4 Sept 2019, 18:41
          1
          • M mrjj
            4 Sept 2019, 18:03

            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 4 Sept 2019, 18:41 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?

            M 1 Reply Last reply 4 Sept 2019, 18:58
            0
            • A ali1377
              4 Sept 2019, 18:41

              @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?

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 4 Sept 2019, 18:58 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 4 Sept 2019, 20:42 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
                • M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 5 Sept 2019, 07:00 last edited by
                  #8

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

                  A 1 Reply Last reply 5 Sept 2019, 08:05
                  0
                  • M mrjj
                    5 Sept 2019, 07:00

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

                    A Offline
                    A Offline
                    ali1377
                    wrote on 5 Sept 2019, 08:05 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 5 Sept 2019, 09:25 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 5 Sept 2019, 13:03
                      0
                      • A ali1377
                        5 Sept 2019, 09:25

                        @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 5 Sept 2019, 13:03 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 5 Sept 2019, 16:14
                        1
                        • A ali1377
                          5 Sept 2019, 13:03

                          @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 5 Sept 2019, 16:14 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

                          5/12

                          4 Sept 2019, 18:41

                          • Login

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