Results 1 to 3 of 3

Thread: Alt + click for a QWidget

  1. #1
    Join Date
    Dec 2007
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Alt + click for a QWidget

    I'd like to be able to catch the alt + click event in my custom widget, but it seems that that event is used by the top level window to be able to move the window around the desktop.

    Is it possible for the top level window to ignore the alt+click event? Maybe I didn't look hard enough, but I couldn't find a solution in the documentation. Does anyone know a solution, or give a hint in what direction I should look?

    The following code illustrates my problem, except for the alt modifier key all other modifier keys can be caught.

    Qt Code:
    1. #include <QtGui>
    2. class Widget : public QWidget {
    3. public:
    4. Widget() : QWidget(){}
    5. protected:
    6. void mousePressEvent(QMouseEvent *me) {
    7. if (me->modifiers() & Qt::AltModifier) {
    8. qDebug("Alt + click");
    9. } else if (me->modifiers() & Qt::ControlModifier) {
    10. qDebug("Control + click");
    11. } else if (me->modifiers() & Qt::ShiftModifier) {
    12. qDebug("Shift + click");
    13. } else if (me->modifiers() & Qt::MetaModifier) {
    14. qDebug("Meta + click");
    15. } else {
    16. qDebug("click");
    17. }
    18. }
    19. };
    20.  
    21. int main(int argc, char **argv)
    22. {
    23. QApplication app(argc, argv);
    24. Widget w;
    25. w.show();
    26. return app.exec();
    27. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Apr 2008
    Posts
    37
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Alt + click for a QWidget

    You need that something happen on the QWidget when you press ALT + CLICK?

  3. #3
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Alt + click for a QWidget

    On many unix desktops, ALT+Left Click Drag moves the window around. THis is handled by the window manager and as far as I know there is no way for you to get around this. Use a different modifier key instead, or provide an alternate way to accomplish this task for those users.

Similar Threads

  1. Double Click Capturing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2011, 14:12
  2. Error in put one QWidget in another QWidget
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2008, 16:05
  3. Replies: 3
    Last Post: 8th March 2007, 14:54
  4. QGraphicsScene Click / Double Click
    By philentropist in forum Qt Programming
    Replies: 1
    Last Post: 9th February 2007, 04:32
  5. Replies: 5
    Last Post: 12th January 2006, 15:40

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.