[solved]QDialog keyPressEvent is not triggered
-
Hi All. I have created a subclass to QDialog.I need to catch mouse click on the dialog window area.But it doesn't work.
Here is my code:@
#include "aboutdialog.h"
#include <qdebug.h>
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent,Qt::FramelessWindowHint | Qt::Popup|Qt::Dialog){
setupUi(this);}
void AboutDialog::keyPressEvent(QKeyEvent *e){
qDebug()<<"About dialog window clicked";
}
void AboutDialog::showEvent(QShowEvent *e){
setFocusPolicy(Qt::StrongFocus);
setFocus(Qt::PopupFocusReason);}
@
What is missing here?ShowEvent gets triggered all right but when I am clicking in the dialog window the keyPressEvent doesn't respond . The UI for the AboutDialog contains only background image.
-
Hi,
keyPresseEvent is for the keyboard, you have the mousePressEvent for the mouse click
-
Indeed,I need to stop working at night ;) Thanks.
-
You're welcome !
If it's working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)