Results 1 to 3 of 3

Thread: Adding Icons to Combobox Items such that Icons are visible at the Right Side

  1. #1
    Join Date
    Apr 2013
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Adding Icons to Combobox Items such that Icons are visible at the Right Side

    I am working on an application in which I need to show the List of Program Names and corresponding Icons in a Combobox Popup Menu.

    I tried following things:

    a. Created the Custom Widget deriving from QCombobox b. ReImplemented the showPopup() function as follows

    void CMyComboBox::showPopup()
    {
    QComboBox::showPopup();
    mp_Popup = this->findChild<QFrame *>();
    mp_Popup->move( mp_Popup->x(), mp_Popup->y() - this->height() - mp_Popup->height() );
    }

    b. Adding Items to Combobox QString Name = "XYZ"; QIcon icon("Sample.png");

    myComboBox->insertItem(0, icon, Name);

    Question is: When I insert using above method, it inserts the Icon at the left side(i.e.., Icon followed by Name) . How do I make the Icons to come at the Right Side(i.e.., Name First then the Icon)

    Regards Santhosh

  2. #2
    Join Date
    Apr 2013
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Adding Icons to Combobox Items such that Icons are visible at the Right Side

    Any answers from this forum for this query.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Adding Icons to Combobox Items such that Icons are visible at the Right Side

    For the icon to appear on the right side you need to provide a custom item delegate that will paint the decoration on the right side of the text instead of the default left side.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 16
    Last Post: 28th February 2011, 10:34
  2. No icons visible in XP System Tray or Listbox?
    By V4Friend in forum Qt Programming
    Replies: 9
    Last Post: 20th July 2010, 20:55
  3. Adding Icons
    By bijan311 in forum Newbie
    Replies: 2
    Last Post: 27th March 2010, 23:43
  4. Replies: 1
    Last Post: 22nd February 2010, 11:53
  5. QIcon Icons are not visible
    By harakiri in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2007, 20:11

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.