Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to make QMenubar visible on Android 4xx?



  • I have a application for Android which I tried to deploy it on multiple Android devices(both physical and AVDs), when it starts it shows the titlebar+menubutton(which is the QMenuBar I added)
    When the application starts it asks the user to enter username and password, after login I replace that menubar with another but the titlebar+menubar disappears without any way to acces it, it only happens on devices which do not have a "menu" option on the device.
    Is there a way to set it visible?

    I am using Qt 5.3.1



  • This might be a bug since I managed to do a workaround, as it only occurs if menubars are changed via @setMenuBar(QMenuBar *menubar)@

    without deleting the current menubar and if there are any methods that modify the widgets inside central's widget layout(deleting,adding) before adding a new menubar.

    In case someone bumps into this, here is my workaround:

    @/* this is the first menubar which I set by default, before login and after the the user disconnects /
    void mainwindow::setMenuBar1(){
    /
    do nothing here /
    if(this->menuWidget()!=NULL){
    delete this->menuWidget();
    mb=new MenuBar1(this);
    setMenuBar(mb);
    }
    else{
    mb=new MenuBar1(this);
    setMenuBar(mb);
    }
    /
    in case it's needed do something here */
    }

    /* this is the menubar which I set after login /
    void mainwindow::setMenuBar2(){
    /
    do nothing here /
    if(this->menuWidget()!=NULL){
    delete this->menuWidget();
    mb=new MenuBar2(this);
    setMenuBar(mb);
    }
    /
    in case it's needed do something here */
    }@

    This workaround works 80%-90% of the time unfortunately. If someone care to help I'm open for tips.


Log in to reply