[Solved]How to show same settings for each option in listview?



  • Hi,
    I am using qt5.1 and developing a GUI. In my mainwindow.ui i have inserted a list view, where some options for user going to display. Now for each option in list view, the same config settings i want to display. But the data related to each options should remain separate, i don't know which is the best way to do it. I thought about tab widget (switching tab for each option) but the number of options are going to change so i cant predesign tabs. And i want to design GUI in mainwindow.ui file not in mainwindow.cpp using those Qtabwidget, QListview etc. classes. Any suggestions please.



  • Hi,

    I suggest to use a Model that store all settings for each option

    On the left side of Form you could use a ListView with all options available. On the center of Form you design widgets needed to show all settings.
    When you change selection on ListView, you select the right ModelIndex and show the related settings



  • Thanks mcosta --For replay, I did as you suggested.
    I want to show my window here, but i don't know how to paste *.png here.
    Anyway, I have a QsqlTableModel, in which all settings are stored. For one option in list view there is one row in model. Now i want to show the values of selected row at different places e.g. first value of selected row in myLineEdit1, second in myLineEdit2 etc. so that user can edit them. And then when he will click on "save" button, i will just do
    @model.submitAll()@

    and model will get updated in database.
    In short is it possible to show single-single entry's of model at different line edits and then directly save model in db?
    Thanks again.



  • Yes, you can.

    You can use the class "QDataWidgetMapper":http://qt-project.org/doc/qt-5/QDataWidgetMapper.html that allows you to map each field of a Model to a widget



  • Cheers...
    Thank you mcosta. QDataWidgetMapper is doing great job for me.
    Thank you.


Log in to reply
 

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