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. Create Font object in QML function
QtWS25 Last Chance

Create Font object in QML function

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.7k 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.
  • L Offline
    L Offline
    luca
    wrote on last edited by
    #1

    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
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      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
      1
      • ? A Former User

        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 Offline
        L Offline
        luca
        wrote on last edited by
        #3

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

        • Login

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