Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved]QDialog keyPressEvent is not triggered
Forum Updated to NodeBB v4.3 + New Features

[solved]QDialog keyPressEvent is not triggered

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sasmaster
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      keyPresseEvent is for the keyboard, you have the mousePressEvent for the mouse click

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sasmaster
        wrote on last edited by
        #3

        Indeed,I need to stop working at night ;) Thanks.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved