Qt Forum

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

    Forum Updated on Feb 6th

    Solved Create Font object in QML function

    QML and Qt Quick
    2
    3
    1255
    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.
    • L
      luca last edited by

      Hi all,
      I need to create a Font object inside a QML function and then pass it to C++ using signal:

      signal mySignal(font my_font)
      
      function myFunction()
      {
          Font font = new Font() (?????)
          ...
          ...
          mySignal(font)
      }
      

      is it possibile?

      Thanks

      1 Reply Last reply Reply Quote 0
      • ?
        A Former User last edited by

        Yes, it's possible. font is a QML basic type, see font QML Basic Type. But you don't use new to create an instance, but the factory function Qt.font(), see font method.

        L 1 Reply Last reply Reply Quote 1
        • L
          luca @Guest last edited by

          @Wieland Thanks!
          I solved in this way:

          signal mySignal(font my_font)
          
          function myFunction()
          {
               var my_font = Qt.font({family: "Sans Serif", pointSize: 32})
               ....
               mySignal(my_font)
          }
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post