Drawing an image next to a QCompleter
-
Hi folks,
I want to draw an image next to a QCompleter when a user cycles through the available options in the QCompleter.
The image in question is potentially larger in height than the QCompleter and can potentially be drawn either on the left hand side or right hand side, depending on where the QCompleter is on the screen and the available space next to it.
I don't have any code for this yet, I'm just wondering what the best approach to something like this would be.
-
QCompleter
has a popup method that gives you the widget used by the completer. Get its geometry and show a label with an image wherever you want it to be in relation to that. -
Thanks, I managed to get it to work and most of my time was trying to not have the QLabel steal focus, be properly parented to the window and be able to render outside the window frame. What solved most of my problems was setWindowFlag(Qt::ToolTip);
One weird thing I encountered was that if I initialize the QLabel with an empty QPixmap(), it never appears on screen, even if I set another image after that. Even when forcing setMinimumSize to specific values.
I solved that by just hiding the QLabel and only showing it when I have an image to show.