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