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. Detect a click on a QMdiArea
Forum Updated to NodeBB v4.3 + New Features

Detect a click on a QMdiArea

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

    Hello,
    I would like to detect clicks on my QMdiArea. It seems very simple but in fact I couldn't manage to do it... What I really want to do is to detect a click on the whole mdi area.
    I mean by this : in any widget contained by the QMdiArea, wether it is the background or a QMdiSubWindow or whatever these QMdiSubWindows may contain ! I already tried to inherit QMdiSubWindow to send a signal to tell it has been clicked. The mousePressEvent has only been received when the user clicked on the title bar of the sub window. If there is a widget in the subwindow, it handles the event then shuts up. MdiSubWindows will never hear of this event.
    How could I force every child of a widget to let me know when it has been clicked, as I don't know them all when compiling as well (some of them are plugins) ? It wouldn't be very handy to reimplement every Qt class to add a clickedOn() signal in every possible Widget (that should be available in Qt I think and the event should be sent to the parent everytime even if the child handles it, and if you don't want that you could just specify a widget attribute or something)...
    The problem seems very simple to resolve but I'm trapped in a dead end, I searched in the whole documentation and I couldn't find anything which allows this. Maybe I didn't search well, I don't know.

    Anyway, thank you for your cooperation !

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      Install an event filter on the QMdiArea:
      http://qt-project.org/doc/qt-4.8/qobject.html#installEventFilter

      If that doesn't work, Install it on all subwidgets, too. (This can be done dynamically during runtime, see http://qt-project.org/doc/qt-4.8/qobject.html#findChildren which gives you all child objects recursively)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dexter9313
        wrote on last edited by
        #3

        Thanks a lot for your answer ! It only works with findChildren() but it works well. The only issue is that I have to make sure that the eventFilter is installed on dynamically allocated widgets during runtime after my main window constructor is set. Anyway, I'll document this for my program's plugin developers.

        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