Results 1 to 4 of 4

Thread: Position of Qt::WindowFlags / Qt::Popup

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Position of Qt::WindowFlags / Qt::Popup

    How i can set position X Y exact 10 px down from start event button?
    or from last mouse position?


    Qt Code:
    1. class Gui_Date : public QWidget, public Ui::Gui_Date
    2. .......
    3. Gui_Date::Gui_Date( QWidget* parent )
    4. : QWidget( parent )
    5. {
    6. Qt::WindowFlags flags = 0;
    7. flags = Qt::Popup;
    8. setWindowFlags(flags);
    9. setupUi( this );
    10. connect( datePicker, SIGNAL( dateChanged(QDate) ), this, SLOT( Updatedate(QDate) ) );
    11. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Position of Qt::WindowFlags / Qt::Popup

    You can move a window to the mouse position with code:
    Qt Code:
    1. move(QCursor::pos());
    To copy to clipboard, switch view to plain text mode 

    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.
    J-P Nurmi

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Position of Qt::WindowFlags / Qt::Popup

    why not run so...

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


    Qt Code:
    1. Gui_Date::Gui_Date( QWidget* parent )
    2. : QWidget( parent )
    3. {
    4. Qt::WindowFlags flags = 0;
    5. flags = Qt::Popup;
    6. setWindowFlags(flags);
    7. mapFromParent(QPoint(100, 100));
    8. setupUi( this );
    9. connect( datePicker, SIGNAL( dateChanged(QDate) ), this, SLOT( Updatedate(QDate) ) );
    10. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Position of Qt::WindowFlags / Qt::Popup

    Quote Originally Posted by patrik08
    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.

Similar Threads

  1. Compare QString alphabet position
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 2nd July 2006, 17:50
  2. set Position
    By mickey in forum Newbie
    Replies: 3
    Last Post: 17th June 2006, 22:30
  3. Qt4.1 Mouse Position & Scaling
    By Paul Drummond in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2006, 20:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.