PDA

View Full Version : Position of Qt::WindowFlags / Qt::Popup



patrik08
3rd July 2006, 09:13
How i can set position X Y exact 10 px down from start event button?
or from last mouse position?




class Gui_Date : public QWidget, public Ui::Gui_Date
.......
Gui_Date::Gui_Date( QWidget* parent )
: QWidget( parent )
{
Qt::WindowFlags flags = 0;
flags = Qt::Popup;
setWindowFlags(flags);
setupUi( this );
connect( datePicker, SIGNAL( dateChanged(QDate) ), this, SLOT( Updatedate(QDate) ) );
}

jpn
3rd July 2006, 09:23
You can move a window to the mouse position with code:


move(QCursor::pos());


but in my opinion this is a bad idea. The mouse cursor might be anywhere on the screen and the window could possibly be misplaced partially out of the screen.

patrik08
3rd July 2006, 09:31
why not run so...

mapFromParent(QPoint(100, 100)); !not work!





Gui_Date::Gui_Date( QWidget* parent )
: QWidget( parent )
{
Qt::WindowFlags flags = 0;
flags = Qt::Popup;
setWindowFlags(flags);
mapFromParent(QPoint(100, 100));
setupUi( this );
connect( datePicker, SIGNAL( dateChanged(QDate) ), this, SLOT( Updatedate(QDate) ) );
}

jacek
3rd July 2006, 15:44
mapFromParent(QPoint(100, 100)); !not work!
Please, read the docs carefully:

QPoint QWidget::mapFromParent ( const QPoint & pos ) const
Translates the parent widget coordinate pos to widget coordinates.