Results 1 to 3 of 3

Thread: Strange behavior: double click/mouse dragging will trigger key event “CTRL-C”

  1. #1
    Join Date
    Feb 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Strange behavior: double click/mouse dragging will trigger key event “CTRL-C”

    Qt seems to behavior strangely: when mouse double click or dragging on a widget, it will trigger the Ctrl-C key event. Here is my code:

    Qt Code:
    1. class CWidget: public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. CWidget()
    7. {
    8.  
    9. };
    10. virtual ~CWidget()
    11. {
    12. }
    13.  
    14. protected:
    15. void keyPressEvent ( QKeyEvent * event )
    16. {
    17. if (event->key() == Qt::Key_C && (event->modifiers() & Qt::ControlModifier))
    18. {
    19. qDebug() << "strange copy: Ctrl-C";
    20. }
    21. QWidget::keyPressEvent(event);
    22. }
    23. }; //
    To copy to clipboard, switch view to plain text mode 

    After the widget is shown, you can perform mouse double click and dragging around on it, and the debug message "strange copy:Ctrl-C" is printed. I have been searching over the internet for two days about this, and found nothing.

    Did I code it wrong or it is a bug of Qt?

    The code is tested under (vs2008 + Qt Addin + Qt 4.7.3) and (qcreator + Qt 4.7.3 ), xp sp2

    Here is the project can be compiled using vs2008 + Qt Addin + Qt 4.7.3:
    CWidget.zip
    Last edited by koderchen; 1st March 2012 at 02:46. Reason: updated contents

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

    Default Re: Strange behavior: double click/mouse dragging will trigger key event “CTRL-C”

    Please provide a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Strange behavior: double click/mouse dragging will trigger key event “CTRL-C”

    Hmmm I can't see any strange behaviour (w7 64bit, qt creator, qt4.6.3/qt4.7.4).

Similar Threads

  1. QTreeWidget Horizontal header double click event???
    By deepal_de in forum Qt Programming
    Replies: 3
    Last Post: 6th June 2011, 09:31
  2. how to disable double click event on qmainwindow titlebar?
    By banlinhtienphong in forum Qt Programming
    Replies: 1
    Last Post: 28th March 2011, 11:23
  3. Replies: 8
    Last Post: 2nd September 2010, 16:49
  4. how to simulate mouse click behavior?
    By hashb in forum Qt Programming
    Replies: 2
    Last Post: 31st August 2010, 08:53
  5. can not get mouse double click event for QGraphicsItem
    By learning_qt in forum Qt Programming
    Replies: 2
    Last Post: 14th September 2009, 21:36

Tags for this Thread

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.