Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Create a QML Rectangle inside a Text object from c++
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 848 Views 1 Watching
  • 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
    Katlin
    wrote on last edited by
    #1

    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" ...

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Katlin
      wrote on last edited by
      #2

      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 ..."

      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