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. Adding QMouseEvent to QFrame created using Designer

Adding QMouseEvent to QFrame created using Designer

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.2k 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.
  • A Offline
    A Offline
    aldolucero
    wrote on last edited by
    #1

    Hello,

    I have been searching for a couple of days for an answer to this:

    I have created a simple window with a QFrame in it using Designer. The QFrame just has 4 QLabels in it. I am trying to figure out how to detect mouse clicks inside the QFrame. The name of the QFrame is frame01.
    I tried creating a class (frame01.cpp and frame01.h) and overriding the mousePressEvent and mouseReleaseEvent methods, but no luck.

    I am wondering if there is an example out there that I have missed. Are things more complicated because I created the window with Designer? I also tried looking to see if I could set it up in Designer, but I could not find any place to set it up.

    Any help would really be appreciated.

    Thanks

    Aldo L.

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      You have two ways to do this.

      1. Reimplement QFrame. But if you want use it with QtDesigner this is not for you.
      2. Install event filter. "Take a look":http://qt-project.org/doc/qt-5/qobject.html#installEventFilter .
      1 Reply Last reply
      0
      • A Offline
        A Offline
        aldolucero
        wrote on last edited by
        #3

        For anyone interested, using the eventFilter worked. It just took me some time to figure out how to correctly create the class that implements the eventFilter(QObject, QEvent) method.

        Thanks qxoz

        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