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. Font property styling

Font property styling

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 4 Posters 6.3k Views
  • 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.
  • K Offline
    K Offline
    korzhp
    wrote on last edited by
    #1

    Hi

    I would make something like this:
    @
    Item
    {
    id: root

    QtObject {
        id:style
        property font mainFont:{ family: "Times"; pointSize: 42; capitalization: Font.AllUppercase }
    }
    
    Text {
        font: style.mainFont
    }
    

    }
    @
    but I've got error in line 7
    it's not possible create property with font type.

    Are there any solution for this situation?

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

      May be I am wrong but I think you should use font-family instead of family.

      Hope you get it

      1 Reply Last reply
      0
      • M Offline
        M Offline
        manolobarea
        wrote on last edited by
        #3

        As a matter of fact, try this

        property font mainFont:{ font-family: "Times"; font-size: 42px; font-variant: small-caps }

        1 Reply Last reply
        0
        • K Offline
          K Offline
          korzhp
          wrote on last edited by
          #4

          It does not work. It's not possible to create property with font type.

          [quote author="manolobarea" date="1289324369"]As a matter of fact, try this

          property font mainFont:{ font-family: "Times"; font-size: 42px; font-variant: small-caps }[/quote]

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mbrasser
            wrote on last edited by
            #5

            Unfortunately the above isn't really possible at the moment. Some alternatives are:

            • Be explicit with each property. (Text { font.family: style.family; font.pointSize: style.pointSize ... })
            • Created a styled, reusable Text element (See e.g. "Styling in QML":http://developer.qt.nokia.com/wiki/QmlStyling)
            1 Reply Last reply
            0
            • B Offline
              B Offline
              blam
              wrote on last edited by
              #6

              You'll need to set the individual font properties like font.family, font.pointSize etc. instead of just setting 'font'.

              You may be interested in this: "http://developer.qt.nokia.com/wiki/QmlStyling":http://developer.qt.nokia.com/wiki/QmlStyling

              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