Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved menu name changing

    Mobile and Embedded
    4
    12
    863
    Loading More Posts
    • 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
      ali1377 last edited by ali1377

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

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • A
          ali1377 @SGaist last edited by

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

          1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion last edited by 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 1 Reply Last reply Reply Quote 1
            • A
              ali1377 @mrjj last edited by

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

              mrjj 1 Reply Last reply Reply Quote 0
              • mrjj
                mrjj Lifetime Qt Champion @ali1377 last edited by

                @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 Reply Quote 1
                • A
                  ali1377 last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • mrjj
                    mrjj Lifetime Qt Champion last edited by

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

                    A 1 Reply Last reply Reply Quote 0
                    • A
                      ali1377 @mrjj last edited by

                      @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 Reply Quote 0
                      • A
                        ali1377 last edited by

                        @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 Reply Quote 0
                        • A
                          ali1377 @ali1377 last edited by

                          @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. Rogina 1 Reply Last reply Reply Quote 1
                          • Pablo J. Rogina
                            Pablo J. Rogina @ali1377 last edited by

                            @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 Reply Quote 1
                            • First post
                              Last post