Results 1 to 3 of 3

Thread: Add close button in In Combobox item.

  1. #1
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Add close button in In Combobox item.

    I am not able to add Close Button in Combobox Item view at right Side, which will act as delete button for the Item. Any one have any idea please help me.

  2. #2
    Join Date
    Sep 2009
    Location
    Aachen, Germany
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Add close button in In Combobox item.

    There are 2 possibilities I can think of right now, both of which are quite complicated:

    1. Subclass QStyledItemDelegate, reimplement createEditor so that it creates the delete button for the second column of a QTableWidget, then use a QTableWidget with that Delegate as the Comboboxes view (with openPersistentEditor)
    2. Subclass QComboBox, reimplement paintEvent so that your delete button is painted and reimplement mousePressEvent so you can detect wether the user clicked on the item oder the items delete button rect.

  3. The following user says thank you to ChiliPalmer for this useful post:

    akram.halder (12th August 2010)

  4. #3
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Add close button in In Combobox item.

    Hi ,

    I tried your secound Idea. But it draws a close button on combobox. It does not display close button on Items(Right side). Please reffer the below code. Correct me please if I am wrong.


    CCustomCombobox::CCustomCombobox(QWidget * parent):
    QComboBox(parent)
    {
    }


    void CCustomCombobox:aintEvent(QPaintEvent *pe )
    {
    QPainter p(this);
    QImage closeImage;
    image.load(":/resource/Icons/Window_Ctrl_Icon_Close.png");
    p.drawImage(100,0,closeImage);

    }

    Regards,
    Akram

Similar Threads

  1. Close button in a tab
    By mitro in forum Newbie
    Replies: 2
    Last Post: 16th May 2008, 10:22
  2. combobox and item colors
    By zorro68 in forum Qt Programming
    Replies: 16
    Last Post: 23rd September 2007, 12:54
  3. Retrieve userData of a comboBox item
    By jiveaxe in forum Newbie
    Replies: 6
    Last Post: 23rd August 2007, 10:28
  4. Can Qtable Item be a comboBox?
    By iGoo in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2006, 09:58

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.