Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Drawing an image next to a QCompleter
Qt 6.11 is out! See what's new in the release blog

Drawing an image next to a QCompleter

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 509 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    riplin
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1
      • R Offline
        R Offline
        riplin
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved