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. How to get the parent's size (height and width in pixels) from child widget?
Forum Updated to NodeBB v4.3 + New Features

How to get the parent's size (height and width in pixels) from child widget?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 2.3k 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.
  • N Offline
    N Offline
    Niagarer
    wrote on 2 Aug 2017, 09:06 last edited by Niagarer 8 Feb 2017, 09:08
    #1

    Hey,
    I have a QGraphicsView and a tabWidget.
    the QGraphicsView is a child of the tabWidget.
    How is it possible to get the size (width and height in pixels) of the tabWidget inside my QGraphicsView?
    I ask this, because I want to block zooming in QGraphicsView before one side of it becomes less than the tabWidget's side.
    Thanks for answers

    R 1 Reply Last reply 2 Aug 2017, 09:16
    0
    • N Niagarer
      2 Aug 2017, 09:06

      Hey,
      I have a QGraphicsView and a tabWidget.
      the QGraphicsView is a child of the tabWidget.
      How is it possible to get the size (width and height in pixels) of the tabWidget inside my QGraphicsView?
      I ask this, because I want to block zooming in QGraphicsView before one side of it becomes less than the tabWidget's side.
      Thanks for answers

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 2 Aug 2017, 09:16 last edited by
      #2

      @Niagarer
      the GraphicsView is inside the tab widget right?
      If so just check the size of the graphicsview itself (or better it's viewport), since it gets resized by the tabwidget automatically.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      N 1 Reply Last reply 2 Aug 2017, 09:42
      0
      • R raven-worx
        2 Aug 2017, 09:16

        @Niagarer
        the GraphicsView is inside the tab widget right?
        If so just check the size of the graphicsview itself (or better it's viewport), since it gets resized by the tabwidget automatically.

        N Offline
        N Offline
        Niagarer
        wrote on 2 Aug 2017, 09:42 last edited by
        #3

        @raven-worx
        Yes, it worked, thanks!
        I can't find a method to get the real size of the QGraphicsScene rectangle in pixels (this number should become smaller when I zoom out). To do what I want, I will need this I guess.
        But this is actually another question.

        R 1 Reply Last reply 2 Aug 2017, 09:47
        0
        • N Niagarer
          2 Aug 2017, 09:42

          @raven-worx
          Yes, it worked, thanks!
          I can't find a method to get the real size of the QGraphicsScene rectangle in pixels (this number should become smaller when I zoom out). To do what I want, I will need this I guess.
          But this is actually another question.

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 2 Aug 2017, 09:47 last edited by
          #4

          @Niagarer said in How to get the parent's size (height and width in pixels) from child widget?:

          I can't find a method to get the real size of the QGraphicsScene rectangle in pixels (this number should become smaller when I zoom out)

          you need to use the mapFromScene() methods.

          view->mapFromScene( view->sceneRect() ).boundingRect()
          

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          N 1 Reply Last reply 2 Aug 2017, 10:30
          1
          • R raven-worx
            2 Aug 2017, 09:47

            @Niagarer said in How to get the parent's size (height and width in pixels) from child widget?:

            I can't find a method to get the real size of the QGraphicsScene rectangle in pixels (this number should become smaller when I zoom out)

            you need to use the mapFromScene() methods.

            view->mapFromScene( view->sceneRect() ).boundingRect()
            
            N Offline
            N Offline
            Niagarer
            wrote on 2 Aug 2017, 10:30 last edited by
            #5

            @raven-worx
            yes, it works, thank you!

            1 Reply Last reply
            0

            1/5

            2 Aug 2017, 09:06

            • Login

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