Results 1 to 5 of 5

Thread: SQL and QItemDelegate problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default SQL and QItemDelegate problem

    I have a table of data with a combo box delegate on one of the columns. I have a problem in creating the delegate efficiently.

    The table data is a joined query so I can have the column I want to edit showing the text it relates to instead of the integer code in the table.

    I can't use a QSqlRelational* object because the related table data is a subset from a table without a useable index and a some WHERE clauses to filter out unrelated rows. My solution is to load the combo box with a query.

    It works, but the combo box is created in the createEditor method, which means every time the field is being edited the query has to be executed. The sensible thing to do here is have the combo box created in the ctr and loaded once...right ?

    My problem is I can't work out how to create the combo box in the ctr. QComboBox requires a QWidget as it's parent (which is supplied via createEditor(QWidget *parent... but the ctr code has a QObject parameter as a parent and the code doesn't compile. This is probably a simple answer but I can't think what it may be. Can anyone help please ?
    Last edited by vieraci; 29th May 2009 at 16:55. Reason: reformatted to look better

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
  •  
Qt is a trademark of The Qt Company.