PDA

View Full Version : frameGeometry vs Geometry



bossy
6th October 2013, 14:43
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


QGraphicsScene *scene = new QGraphicsScene();
myview = new QGraphicsView(scene);
QRect myrect = this->geometry();
QRect frameRect = this->frameGeometry();

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

thanks

anda_skoa
11th October 2013, 09:41
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,
_

bossy
13th October 2013, 13:06
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

anda_skoa
13th October 2013, 15:02
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,
_

bossy
18th October 2013, 00:55
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



void MainWindow::timer()
{
QRect myrec = myview->geometry();
QRect myrec2 = myview->frameGeometry();
int y1 = myrec.y();
int x1 = myrec.x();
int x2 = myrec2.x();
int y2 = myrec2.y();
mydialog->move(x1-x2,y1-y2);
}