Create a QML Rectangle inside a Text object from c++



  • How can I create a Rectangle inside a Text object, from c++ ?
    The purpose is to be able to see the actual label position and especially size, in order to debug it.

    In QML I would do:
    @
    Text{

    id:some_text
    text:"some text here"
    
    Rectangle{
        id:the_border
        anchors.fill:parent
        border.color:"#000000";
        color:"#00000000";
    }
    

    }
    @

    So how can I do this in c++?
    I have created my label as

    @
    QQuickText *myLabel;
    myLabel = new QQuickText(its_parent);
    @

    Then I immagine I have to do something like

    @
    QTheRectanglesClass *theOutline;
    theOutline = new QTheRectanglesClass(myLabel);
    @

    But I don't know the "QTheRectanglesClass" ...



  • Update: I've tried using QQuickRectangle (and included the private/qquickrectangle_p.h header) but I get the error: LNK2019: unresolved external symbol "public: __cdecl QQuickRectangle::QQuickRectangle(class QQuickItem *)" (??0QQuickRectangle@@QEAA@PEAVQQuickItem@@@Z) referenced in function ..."


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.