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. Surface3D size is just 1x1
Qt 6.11 is out! See what's new in the release blog

Surface3D size is just 1x1

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 200 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.
  • Tom assoT Offline
    Tom assoT Offline
    Tom asso
    wrote on last edited by Tom asso
    #1

    I'm writing a QML application with C++ singleton back-end.
    My qml defines an Item which contains a Surface3D:

    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Item {
            width: 640
            height: 480
            objectName: "surface3DItem"
    
            Surface3D {
    	    objectName: "surface3D"
                width: parent.width
                height: parent.height
    

    After my C++ is instantiated, my code reads the width and height of Item (named "surface3DItem") and width and height of Surface3D (named "surface3D"):

    object = g_rootWindow->findChild<QObject *>("surface3DItem");
    qDebug() << "surface3DItem width: " << ((QQuickItem *)object)->width();
    qDebug() << "surface3DItem height: " << ((QQuickItem *)object)->height();
    
    object = g_rootWindow->findChild<QObject *>("surface3D");
    qDebug() << "surface3D width: " << ((Surface3D *)(object)->width();
    qDebug() << "surface3D height: " << ((Surface3D *)(object)->height();
    

    Since my qml explicitly specifies Item width=640 and height=480, I would expect the enclosed Surface3D to have the same. But instead my app prints:

    surface3DItem width:  640
    surface3DItem height:  480
    surface3D width:  1
    surface3D height:  1
    

    Why is the Surface3D only 1x1, while its parent Item is 640x480?

    Thanks
    Tom

    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