Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]How to set single column from Qsqltablemodel to Qlistview?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashokb
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      To set the column you want to use just call setModelColumn

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ashokb
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          clochydd
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved