menu name changing



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


  • Lifetime Qt Champion

    Hi,

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



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


  • Lifetime Qt Champion

    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.



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


  • Lifetime Qt Champion



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


  • Lifetime Qt Champion

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



  • @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);


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



  • @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.



  • @ali1377 said in menu name changing:

    it has been solved

    so please mark your post as such! Thanks


 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.