PDA

View Full Version : Qt widget issue.



bunjee
22nd July 2007, 19:03
Hey trolltechs,

Here is a piece of code


QPoint point = mClientView->.mapToGlobal(QPoint(0,0));

mNewAccountView.move(point.x() - mNewAccountView.width() - 18, point.y());

mNewAccountView.setFixedWidth(200);

mNewAccountView.setWidget(mNewMasterWidget);

mNewAccountView.show();

mNewAccountView.update();



As you can see I'm moving a widget and then setting it visible.

Even after show and update call, the window won't move to the new location, just as if it wasn't repaint.


Is there an instant move function method ?



Thanks.

Mr AreNow.

marcel
22nd July 2007, 19:19
OK. First of all the code you posted is out of context.
I can only assume what are the types involved: mNewAccountView is a QScrollArea and mNewMasterWidget is ....????.

Anyway, your code should work fine as long as there is no layout managing the position of mNewAccountView.
If you have a layout set in the parent of mNewAccountView calling move won't have any effect, at best.

So, maybe you could explain better what you want to achieve.
If you only want to manually layout widgets then:
1) Create your own layout manager(QLayout) that only positions the widget at it's local coordinates( you will have to set these at instantiation time ). Of course, you can make it smarter - if you don't pass the position or if it overlaps with an existing widget, then it will find an optimal position.

2)Do not set a layout to the parent and do what you do now: use move.

Regards