[Solved]How to set single column from Qsqltablemodel to Qlistview?



  • Hi,
    I have a Qsqltablemodel in which there is a table from sql database. now i want to give only one column to edit to user and i want to store that table again in database after save button clicked . So, i have added a Qlistview in mainwindow.ui. But it seems very difficult to add one single column from model to this view. Is there any class which will give me directly one column which i can set to list view and after editing can easily add in that model again ?


  • Lifetime Qt Champion

    Hi,

    To set the column you want to use just call setModelColumn

    Hope it helps



  • Hi, it works. I just added two lines of code
    @ui->lstModels->setModel(model);
    ui->lstModels->setModelColumn(1);@

    and its working now thanks. How to mark it solved?



  • Hi, simply add [SOLVED] to the title of your first post.


Log in to reply
 

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