1

I hosted a QWinWidget in a CView and want it to stay at a designated position when resizing. But QWinWidget always moves to (0, 0), i.e. left-top corner of the CView.

I tried to debug in this way:

QWinWidget* pWidget = new QWinWidget(pCView);
pWidget->move(50, 50);
QPoint pos = pWidget->pos();

Note that: the pos is always (0, 0).

Why is that?

Adam W
  • 3,648
  • 22
  • 18
Kevin C.
  • 271
  • 3
  • 8

2 Answers2

0

I believe you would need to create a child QWidget of the QWinWidget to be able to position it. However, I have never used the mfc-migration tool kit.

Adam W
  • 3,648
  • 22
  • 18
  • Yes, there is a child QWidget. Moving the child QWidget does not affect QWinWidget's position. I found that QWinWidget does not have parent QWidget, while the QWidget.pos() is the position in its parent widget coordinate, so it is always zero. – Kevin C. May 27 '10 at 01:34
0

You may need to firstly show the widget, then move:

pWidget->show();
pWidget->move( 50, 50 );
Mason Zhang
  • 3,423
  • 24
  • 35