Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我按照此处的示例创建了一个 Qt 软件输入面板 (SIP) ,它运行良好。不幸的是,当两个对话框都失去焦点时,单击 SIP 不会将焦点恢复到任一小部件。总而言之,当我:
我们发现这种行为有点奇怪和怀疑,我们的用户也会如此。当两个小部件都失去焦点时,有没有办法通过单击 SIP 将焦点恢复到目标对话框?
解决了。QApplication::setActiveWindow()像这样使用:
QApplication::setActiveWindow()
void KeyboardPanel::buttonClicked( QWidget *widget ) { if( m_lostFocus ) { QWidget* parentWidget = m_lastFocusedWidget->parentWidget(); if( parentWidget ) QApplication::setActiveWindow( parentWidget ); } }