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. QApplication::focusWidget() and QApplication::focusObject()

QApplication::focusWidget() and QApplication::focusObject()

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.6k Views
  • 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.
  • Y Offline
    Y Offline
    yanner
    wrote on last edited by
    #1

    What's the difference other than the return type?

    In addition, in my app the focusWidget() is returning 0 and focusObject() is returning an object to QML textinput. How can that be that both are not returning a pointer? I am using Qt5 and earlier in Qt4.8 focusWidget() used to work OK. I am trying to use QApplication::sendEvent with focusWidget() return value as the first parameter but it crashes because focusWidget() returns 0. If I use focusObject() then the keyEvent is not delivered.

    1 Reply Last reply
    0
    • 3 Offline
      3 Offline
      3.141592
      wrote on last edited by
      #2

      afaik in QT5 there is only QGuiApplication::focusObject () and QWindow::focusObject which would both differ from the functions in Qt 4.8 that the will return the QObject that will be the final receiver of events tied focus (looking at the documentation..) whereas focusWidget() in bith cases (Qt5 and 4.8) will return the widget which has keyboard input focus or 0 if no widget in your application has the focus.

      i think the way to go should be to test if you got a 0-pointer and handle it correctly

      hope that will help you

      kind regards
      christian

      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