How can I display/edit QSqlRelationalTableModel using custom input widgets in a QScrollArea



  • I was hoping someone could lead me in the right direction. I have created a custom widget with several QLineEdits and QComboBoxes. I am using the widget to display/edit contact addresses in a database.

    I have been able to display/edit one address at a time using the custom widget, QSqlRelationalTableModel and QDataWidgetMapper and a "Next" & "Previous" Button. I would like to be able to show all the addresses in the custom widget but have them in a list type view so I can see them on the same screen.

    I have managed to get the widgets to display in a scroll area, but I am not sure what I need to do so the data is displayed in its own “row”. I know I can use QDataWidgetMapper->toNext() and do it “by hand”. But I would like to use the model/view architecture and have it done automatically.

    I saw the chart example and it uses a subclass of QAbstractItemView. It of course is completely different than my “homemade table” so I am not sure if thats where I should be looking for my answers.

    I have attached a photo of the empty widgets listed in the scroll area as a visual cue.

    So my questions:
    Is this possible?
    If so, what class should I be using?

    !https://dl.dropboxusercontent.com/u/107816931/CustomWidgetOnScrollArea.png(customwidgetonscrollarea)!


  • Lifetime Qt Champion

    Hi,

    You should consider using a QListView + a custom QStyledItemDelegate. Otherwise, you can also use setCurrentItem on your QDataWidgetMapper.

    Hope it helps


Log in to reply
 

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