Qt: How to display only Image and hide text in a QCombobox



  • I have a Combobox which has 3 items i.e. Item 1, Item 2 and item 3. I added these 3 items in .ui file and also added an image each for all. Now when I am running the application, it shows the first item in combobox along with a image towards left. When i click on dropdown, I can see all the items along with images.

    What I basically want to do is just display the image in the combobox and when user clicks on dropdown, it should show the image and text too.

    Scenario: Items and images inside Combobox are added as follows:

    Image 1 Item 1
    Image 2 Item 2
    Image 2 Item 3

    When I run the app, it should display in combobox as

    Image1 since first item gets displayed by default.



  • I think you need to delegate items for your combo box. This topic may be helpful: "SOLVED - QT 4.7 QComboBox Custom Item Delegate Doesn’t affect the current item displayed":http://qt-project.org/forums/viewthread/17880



  • But this is when Combobox is set dynamically. I mean when it is set programmatically. I am doing it vai .ui file. I tried the above method but it doesn't make any difference.
    [quote author="AcerExtensa" date="1355825009"]I think you need to delegate items for your combo box. This topic may be helpful: "SOLVED - QT 4.7 QComboBox Custom Item Delegate Doesn’t affect the current item displayed":http://qt-project.org/forums/viewthread/17880[/quote]



  • If you want some extra/custom functionality, you should do it yourself... or use it as is....


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.