[Interest] Making a "popup" QLineEdit

André Somers andre at familiesomers.nl
Fri Oct 18 14:57:18 CEST 2013


Op 18-10-2013 14:05, Etienne Sandré-Chardonnal schreef:
> Dear all,
>
> I want to do the following GUI element : a QLineEdit which popups when 
> some control is clicked, allowing the user for text input, and which 
> hides when enter is pressed, or when the user clicks outside the 
> QLineEdit.
>
> How can this be implemented? In other words, I'm looking for an 
> undecorated floating widget (modal?) and getting an event when the 
> user clicked outside.
>
> Thanks,
>
> Etienne
Try popping up a QLineEdit with parent set to 0, and call this on it:
myLineEdit->setWindowFlags(Qt::ToolTip|Qt::Window);

You can also play around with other window flags of course. Obviously, 
you will need to position the line edit before showing, relative to the 
widget it is connected to. Take care that the coordinate system of a 
widget with a parent is relative to its parent, while that of a a widget 
without a parent is the global coordinate system. So, use 
QWidget::mapToGlobal from your 
widget-that-needs-to-show-a-popup-line-edit to get its global coordinates.

André

-- 
You like Qt?
I am looking for collegues to join me at i-Optics!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131018/c2444e8a/attachment.html>


More information about the Interest mailing list