PDA

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



koderchen
29th February 2012, 21:04
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:


class CWidget: public QWidget
{
Q_OBJECT

public:
CWidget()
{

};
virtual ~CWidget()
{
}

protected:
void keyPressEvent ( QKeyEvent * event )
{
if (event->key() == Qt::Key_C && (event->modifiers() & Qt::ControlModifier))
{
qDebug() << "strange copy: Ctrl-C";
}
QWidget::keyPressEvent(event);
}
}; //

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:
7454

wysota
29th February 2012, 21:47
Please provide a minimal compilable example reproducing the problem.

Spitfire
5th March 2012, 12:09
Hmmm I can't see any strange behaviour (w7 64bit, qt creator, qt4.6.3/qt4.7.4).