Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Font property styling

    QML and Qt Quick
    4
    6
    5910
    Loading More Posts
    • 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
      korzhp last edited by

      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 Reply Quote 0
      • M
        manolobarea last edited by

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

        Hope you get it

        1 Reply Last reply Reply Quote 0
        • M
          manolobarea last edited by

          As a matter of fact, try this

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

          1 Reply Last reply Reply Quote 0
          • K
            korzhp last edited by

            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 Reply Quote 0
            • M
              mbrasser last edited by

              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 Reply Quote 0
              • B
                blam last edited by

                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 Reply Quote 0
                • First post
                  Last post