Results 1 to 3 of 3

Thread: custom display in a QComboBox

  1. #1
    Join Date
    Jun 2010
    Location
    Cincinnati, Ohio, USA
    Posts
    92
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question custom display in a QComboBox

    A model SessionListSqlModel, which derives from QSqlTableModel, is set as the model to a QComboBox control. What should be displayed is a compound string from multiple columns. What is the correct way to do this?

    My first thought is to set QComboBox's modelColumn to one value higher then there are columns. The in the model override the data function and build the compound string for the new column.

    But is there some way I could do the same type of thing with a QItemDelegate? I would prefer to use a QItemDelegate because later I might end up using this model else where and I would really prefer not to have something that is specific to this combo box in the model.

    Sam

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: custom display in a QComboBox

    ? Whats about QComboBox::setItemDelegate()?

    EDIT: If you don't know how to access other column in the delegates paint method: QModelIndex::sibling(),

  3. #3
    Join Date
    Jun 2010
    Location
    Cincinnati, Ohio, USA
    Posts
    92
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: custom display in a QComboBox

    Do you know if there is an example of what I am trying to do somewhere in the world?

Similar Threads

  1. display custom widget in a TableView
    By code_talker in forum Qt Programming
    Replies: 4
    Last Post: 4th August 2012, 21:40
  2. QComboBox Custom Widget has missing designer properties
    By vieraci in forum Qt Programming
    Replies: 5
    Last Post: 9th December 2009, 13:30
  3. QComboBox in QTableWidget : display troubles.
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2007, 23:29
  4. QScrollArea display custom QLabel
    By spawnwj in forum Qt Programming
    Replies: 6
    Last Post: 6th December 2006, 03:38
  5. Replies: 3
    Last Post: 12th April 2006, 08:20

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.