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 botto开发者_高级运维m 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.
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();
}
I don't think you can force the menu bar to be at the bottom of the screen. However, you can either:
1) use the integrated menuBar() function to get the real menu bar and set up the menus the way the native OS (like symbian) wants you to.
2) create your own menu-bar-ish thing by simply creating a QHBoxLayout and adding buttons to it that each create a pop-up menu. It would be very similar to a menu bar once you got done. You'll likely want to play around with button relief layouts though.
精彩评论