Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to change a menubars style? (Example ?)
Forum Updated to NodeBB v4.3 + New Features

How to change a menubars style? (Example ?)

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 3 Posters 3.4k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    themts
    wrote on last edited by
    #1

    Hey guys,

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

    thanks
    CU
    mts

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

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

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        themts
        wrote on last edited by
        #3

        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: messageDialog.show(qsTr("Open action triggered"));
                    }
                    MenuItem {
                        text: qsTr("E&xit")
                        onTriggered: Qt.quit();
                    }
                }
            }
        
        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by mcosta
          #4

          Hi,

          I cannot test it but you can do something like:

          menuBar: MenuBar {
              style: MenuBarStyle {
                  background: Rectangle {
                        color: Qt.black
                  } 
                  font: ....
              }
          }
          

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          0
          • T Offline
            T Offline
            themts
            wrote on last edited by themts
            #5

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

            p3c0P 1 Reply Last reply
            0
            • M Offline
              M Offline
              mcosta
              wrote on last edited by
              #6

              Sorry,

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

              Once your problem is solved don't forget to:

              • Mark the thread as SOLVED using the Topic Tool menu
              • Vote up the answer(s) that helped you to solve the issue

              You can embed images using (http://imgur.com/) or (http://postimage.org/)

              1 Reply Last reply
              0
              • T themts

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

                p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #7

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

                QGuiApplication app(argc, argv);
                QQmlApplicationEngine engine;
                engine.load(QUrl(QStringLiteral("qrc:///Example.qml")));
                QPalette customPalette(app.palette());
                customPalette.setColor(QPalette::WindowText,QColor("yellow"));
                app.setPalette(customPalette);
                return app.exec();
                

                157

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved