How to change a menubars style? (Example ?)

  • Hey guys,

    is there any example how to style a menubar?
    I need a dark menubar (like qt-creator theme dark)


  • Hi,

    according to this you have to define the background and the font components of the style

  • ehh, but how?
    Could you give me a code-snipset?

    lets say this is the menu:

        menuBar: MenuBar {
            Menu {
                title: qsTr("&File")
                MenuItem {
                    text: qsTr("&Open")
                    onTriggered:"Open action triggered"));
                MenuItem {
                    text: qsTr("E&xit")
                    onTriggered: Qt.quit();

  • Hi,

    I cannot test it but you can do something like:

    menuBar: MenuBar {
        style: MenuBarStyle {
            background: Rectangle {
            font: ....

  • @mcosta
    Thanks, this brought me closer. I didn't know that I can simply set a rectangle as background.

    Can you tell me how to change the font-color as well?

  • Sorry,

    I don't remember now. But in the docs there is an example that show how to define "Android" like style

  • Moderators

    @themts You can set a custom palette to the application itself. For eg:

    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;
    QPalette customPalette(app.palette());
    return app.exec();

Log in to reply

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