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. MenuBarStyle, setting the font
Forum Updated to NodeBB v4.3 + New Features

MenuBarStyle, setting the font

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 1.5k Views 1 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.
  • M Offline
    M Offline
    Marcelo SZ
    wrote on last edited by
    #1

    Need to change the font of a Menubar. However, this code doen`t seem to work

    menuBar: MenuBar {
        style: MenuBarStyle {
            background: Rectangle {
                color: "#FFFFFF"
            }
            font: "Microsoft JhengHei UI"
        }
        Menu {
            title: "&File"
            MenuItem { text: "Quit"; onTriggered: Qt.quit() }
    
        }
        Menu {
            title: "&Help"
            MenuItem { text: "About..." ; onTriggered: aboutBox.open() }
        }
    }
    

    The error is:
    qrc:/MainWindow.qml:51 Invalid property assignment: unsupported type "QFont"

    What am I missing?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi! The correct way to do it is either like this:

              style: MenuBarStyle {
                  background: Rectangle {
                      color: "#FFFFFF"
                  }
                  font { family: "Comic Sans MS"; pixelSize: 20; capitalization: Font.AllUppercase } // no ":"
              }
      

      or like that:

          menuBar: MenuBar {
              style: MenuBarStyle {
                  background: Rectangle {
                      color: "#FFFFFF"
                  }
                  font.family: "Comic Sans MS"
                  font.pixelSize: 20
                  font.capitalization: Font.AllUppercase
              }
      
      1 Reply Last reply
      2

      • Login

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