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 Update on Monday, May 27th 2025

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
  • 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.
  • NiagarerN Offline
    NiagarerN Offline
    Niagarer
    wrote on last edited by Niagarer
    #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

    raven-worxR 1 Reply Last reply
    0
    • NiagarerN Niagarer

      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

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on 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

      NiagarerN 1 Reply Last reply
      0
      • raven-worxR raven-worx

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

        NiagarerN Offline
        NiagarerN Offline
        Niagarer
        wrote on 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.

        raven-worxR 1 Reply Last reply
        0
        • NiagarerN Niagarer

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

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on 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

          NiagarerN 1 Reply Last reply
          1
          • raven-worxR raven-worx

            @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()
            
            NiagarerN Offline
            NiagarerN Offline
            Niagarer
            wrote on last edited by
            #5

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

            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