Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Keyboard input if QLineEdit on frameless popup window

Tags:

qt

When a parent widget is defined with:

setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);

Any edit box widget placed on top of it will not receive keyboard input. Mouse will work, right click, context menu, paste will work -- but not direct keyboard input. Any ideas why and how it can be fixed?

like image 423
JasonGenX Avatar asked Oct 04 '11 21:10

JasonGenX


1 Answers

As I mentioned previously in a comment I had the same problem but now it is fixed with the following code:

// virtual override
void MyDialog::showEvent( QShowEvent* aShowEvent )
{
    QDialog::showEvent( aShowEvent );
    activateWindow();
}

After I added the activateWindow() function call I could use QLineEdit on my popup dialog.

I use Visual Studio 2013 and Qt 5.4.1 on Windows 8.1.

like image 55
p.i.g. Avatar answered Oct 07 '22 03:10

p.i.g.