[SOLVED]qt activatewindow windows witn input not work
-
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);
@ -
What I needed to do:
@
HWND hwndActiveWin = GetForegroundWindow();
int idActive = GetWindowThreadProcessId(hwndActiveWin, NULL);
if ( AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) )
{
AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
}
@