Results 1 to 4 of 4

Thread: How do I natively move a QWidget top-level window?

  1. #1
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face How do I natively move a QWidget top-level window?

    Is there any way I can "natively" move a QWidget? For example, Windows can use the gray rectangle when you move a window, while an X11 setup with Compiz can use Wobbly Windows. On X11(Ubuntu 7.10), moving the window by just using:

    Qt Code:
    1. void myapp::mousePressEvent(QMouseEvent *event) {
    2. if (event->button() == Qt::LeftButton) {
    3. dragPosition = event->globalPos() - frameGeometry().topLeft();
    4. event->accept();
    5. }
    6. }
    7.  
    8. void myapp::mouseMoveEvent(QMouseEvent *event) {
    9. if (event->buttons() & Qt::LeftButton) {
    10. move(event->globalPos() - dragPosition);
    11. event->accept();
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    makes it directly paint every time it is dragged, however moving it while pressing and holding the Alt-key yields the wobbly effect. Is there any way I can natively move the window without requiring the user to, for example, hold the Alt key, or is this out of the question?

    Thanks in advance ~codeslicer

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How do I natively move a QWidget top-level window?

    You can probably send an X11 event for moving a window. The wobbly effect (or any other) comes from the window manager - if you want it to be present, you have to move the window through the window manager (for example by holding alt or by dragging the window decoration).

  3. #3
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Wink Re: How do I natively move a QWidget top-level window?

    Ok... that's exactly what I said.
    How would I send a command to the window manager, does it have to be platform-dependent or can there be a platform independent way too?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How do I natively move a QWidget top-level window?

    As I already said, you need to send an X11 event to the window and hopefully that will go through the window manager.

Similar Threads

  1. Replies: 4
    Last Post: 4th June 2007, 12:07
  2. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41
  3. Move window in Clone Mode
    By ultrabrite in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2006, 18:22

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.