Search code examples
qtqt4nokiamenubar

Making a custom menubar in Qt


I'm developing a mobile app using Qt for s60 v5 and symbain 3. Now I want a menubar at bottom of the screen. It should have OPtions button, Exit button. And an additional button in between them. How can this be done? I tried a few things but couldn't get menubar to place at the bottom of the screen. I would like some pointers for creating custom menubar and placing it at whatever place i want. Preferably it should look native.


Solution

  • You can place a non-native QMenuBar in a layout just like any other widget. Below is an example application.

    #include <QApplication>
    #include <QMenuBar>
    #include <QVBoxLayout>
    
    int main(int argc, char **argv)
    {
        QApplication app(argc, argv);
        QWidget window;
        QVBoxLayout layout(&window);
        QMenuBar menubar(&window);
    
        layout.addStretch();
        menubar.addMenu("&File");
        layout.addWidget(&menubar);
        window.show();
    
        return app.exec();
    }