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]qt activatewindow windows witn input not work
QtWS25 Last Chance

[SOLVED]qt activatewindow windows witn input not work

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

    Hello everybody, I faced with a big problem. I need on press global shortcut show widget with QLineEdit. Widget appeares, but sometimes it dont have input focus. For example, if I intered some info in text file, and press shortcut, widget appeares, but if i countinue type, character will be added to that text file, not in my lineEdit. OS: windows. I don't care if I will use winApi.
    When i show widget, i use in main.cpp:
    @
    t->raise();
    t->activateWindow();
    t->showStandart();
    @

    terminal.cpp:
    @
    void Terminal::showStandart()
    {
    m_lineEdit.clear();
    QPixmap pix1("conditionWaiting.png");
    label.setPixmap(pix1);
    timer.stop();
    this->show();
    m_lineEdit.activateWindow();
    }
    @

    I tried to use winApi, but it doesn't help

    @
    QWindow *w = t->windowHandle();
    HWND hwnd = (HWND)QGuiApplication::platformNativeInterface()->nativeResourceForWindow(QByteArrayLiteral("handle"), w);
    SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
    @

    1 Reply Last reply
    0
    • P Offline
      P Offline
      peres94
      wrote on last edited by
      #2

      What I needed to do:
      @
      HWND hwndActiveWin = GetForegroundWindow();
      int idActive = GetWindowThreadProcessId(hwndActiveWin, NULL);
      if ( AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) )
      {
      AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
      }
      @

      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