Results 1 to 5 of 5

Thread: frameGeometry vs Geometry

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default frameGeometry vs Geometry

    I read a few post about this and somehow I'm still not clear on how i get the frame size of my main window.

    in this exemple, geometry and frameGeometry only have 1 of difference. I get the same result if i query after the window is painted

    Qt Code:
    1. myview = new QGraphicsView(scene);
    2. QRect myrect = this->geometry();
    3. QRect frameRect = this->frameGeometry();
    To copy to clipboard, switch view to plain text mode 

    ultimately i want to be able to move my child widget only within the frame of my main window

    thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: frameGeometry vs Geometry

    The child's coordinates are always inside the parent, starting witn 0/0 in the top left corner.

    Why do you want to move the child manually?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2012
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: frameGeometry vs Geometry

    to animate the child windows

    the documentation seems pretty clear:
    "Excluding the window frame: geometry(), width(), height(), rect(), and size().
    Note that the distinction only matters for decorated top-level widgets. "

    however i cant get this kind of result

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: frameGeometry vs Geometry

    If it is not a top level window I would just ignore frameGeometry().
    The rectange returned by geometry() should be the same values that x(), y(), width() and height() return

    Cheers,
    _

  5. #5
    Join Date
    Jan 2012
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: frameGeometry vs Geometry

    after a few hours of playing around, I manage to make it work, problem is it has to be done after the mainwindow is painted, with a timer i used the following code

    Qt Code:
    1. void MainWindow::timer()
    2. {
    3. QRect myrec = myview->geometry();
    4. QRect myrec2 = myview->frameGeometry();
    5. int y1 = myrec.y();
    6. int x1 = myrec.x();
    7. int x2 = myrec2.x();
    8. int y2 = myrec2.y();
    9. mydialog->move(x1-x2,y1-y2);
    10. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 3
    Last Post: 7th July 2011, 12:07
  2. Geometry shader with QT4.7
    By saraksh in forum General Programming
    Replies: 3
    Last Post: 28th March 2011, 16:40
  3. Can't get geometry() in form constructor
    By kartun in forum Qt Programming
    Replies: 5
    Last Post: 29th January 2011, 13:03
  4. How to get frameGeometry without showing the window
    By mortoray in forum Qt Programming
    Replies: 0
    Last Post: 4th December 2010, 15:22
  5. QGraphicsLayout::geometry()
    By isutruk in forum Qt Programming
    Replies: 1
    Last Post: 19th October 2009, 15:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.