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. QML object size within a Qt (C++) gridlayout
Forum Updated to NodeBB v4.3 + New Features

QML object size within a Qt (C++) gridlayout

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

    I have a Qt (C++) gridlayout. One of the objects in this layout is a QQuickWidget and one of the SizePolicies of this QQuickWidget widget is Expanding, so the size of the QQuickWidget can vary. I also construct a ChartView in QML and I display this in the QQuickWidget. I luse C++ to load the ChartView into the QQuickView and to display it. The work of the QML is to construct the ChartView. Diagramatically:

    QML ----------> Qt
    QChartView -> QQuickView

    My problem is to ensure that the ChartView fills the whole screen area available to the QQuickView. At the moment I need to specify the width and height of the Chartview in pixels and the size of the ChartView is not dynamically scaled to that of the enclosing QQuickView. See attached image.

    Screenshot from 2020-10-26 11-56-16.png image url)

    The value of parent.width is zero, so that is not useful. If I do not specify height/width of the ChartView, they are assumed to be zero so nothing is displayed.

    Is there a way to scale the ChartView to fill the whole of the available screen space?

    Gojir4G 1 Reply Last reply
    0
    • W willemf

      I have a Qt (C++) gridlayout. One of the objects in this layout is a QQuickWidget and one of the SizePolicies of this QQuickWidget widget is Expanding, so the size of the QQuickWidget can vary. I also construct a ChartView in QML and I display this in the QQuickWidget. I luse C++ to load the ChartView into the QQuickView and to display it. The work of the QML is to construct the ChartView. Diagramatically:

      QML ----------> Qt
      QChartView -> QQuickView

      My problem is to ensure that the ChartView fills the whole screen area available to the QQuickView. At the moment I need to specify the width and height of the Chartview in pixels and the size of the ChartView is not dynamically scaled to that of the enclosing QQuickView. See attached image.

      Screenshot from 2020-10-26 11-56-16.png image url)

      The value of parent.width is zero, so that is not useful. If I do not specify height/width of the ChartView, they are assumed to be zero so nothing is displayed.

      Is there a way to scale the ChartView to fill the whole of the available screen space?

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @willemf Hi,

      Did you set the resizeMode of your QQuickWidget to QQuickView::SizeRootObjectToView. According to the doc it should resize your root QML element according to QQuickWidget size.

      W 1 Reply Last reply
      3
      • Gojir4G Gojir4

        @willemf Hi,

        Did you set the resizeMode of your QQuickWidget to QQuickView::SizeRootObjectToView. According to the doc it should resize your root QML element according to QQuickWidget size.

        W Offline
        W Offline
        willemf
        wrote on last edited by
        #3

        @Gojir4
        This was indeed the solution. Thank you very much.

        1 Reply Last reply
        1

        • Login

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