PDA

View Full Version : set Position


mickey
17th June 2006, 19:58
hi, I need to set the position of a myFancypopup object; it appear when I click a pushButton....but it position is always at the top-left corner...thanks.

FancyPopup::FancyPopup( QWidget* parent, const char* name ):
QLabel( parent, name, WType_Popup ){
setFrameStyle( WinPanel|Raised );
setAlignment( AlignCenter );
resize(130,200);
}
void myMainForm::showPopup() {
popup->mapFromParent(QPoint(150, 100));
popup->show();
}

jacek
17th June 2006, 21:42
QPoint QWidget::mapFromParent ( const QPoint & pos ) const
Translates the parent widget coordinate pos to widget coordinates.
Same as mapFromGlobal() if the widget has no parent.
This method returns the translated point.

void myMainForm::showPopup()
{
popup->move( mapToGlobal( QPoint( 150, 100 ) ) );
popup->show();
}

mickey
17th June 2006, 22:22
Thanks, but I need put it onto a tabwidget3.Why this does not work?

popup->move( mapToGlobal( QPoint(tabWidget3->x(), tabWidget3->y() )) );

jacek
17th June 2006, 22:30
Why this does not work?
How it "does not work"? Most likely tabWidget3 is not a direct child of "this" widget. You might try:
popup->move( tabWidget3->mapToGlobal( QPoint( 0, 0 ) ) );