Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    How to set the focus fixed for a particular Widget

    General and Desktop
    2
    3
    1256
    Loading More Posts
    • 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.
    • R
      Raagini last edited by

      I have a QWidget (Widget_X). In Widget_X am using few QLineEdits in it. Whenever i press on the QLineEdit a new QWidget (Widget_Y) pops up. In Widget Y , i have few QPushButtons in it. _ whenever the QLineEdit is pressed the Focus will be changed to the new widget (Widget_Y). But, i want the focus to be in Widget_X always (Always Widget_X has to be active ). Even when am pressing the QPushButtons from Widget_Y, still the focus has to be in Widget_X, but the click event of Widget_Y should also be accepted. Please help me on how to achieve this.

      1 Reply Last reply Reply Quote 0
      • M
        Macro last edited by

        Did you find any solution for this? If yes, please post your solution here. Because, currently i am also facing a similar problem .

        1 Reply Last reply Reply Quote 0
        • M
          Macro last edited by

          Hi...
          I hope that the below given code will help you to fix your problem.

          @bool yourWidget::nativeEvent(const QByteArray &eventType, void *message, long *result)
          {
          #ifdef Q_OS_WIN
          if(eventType == "windows_generic_MSG")
          {
          const MSG *msg = reinterpret_cast<MSG *>(message);
          if(msg->message == WM_MOUSEACTIVATE)
          {
          *result = MA_NOACTIVATE;
          return true;
          }
          }
          #endif
          return false;
          }@

          1 Reply Last reply Reply Quote 0
          • First post
            Last post