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. model ?
Forum Updated to NodeBB v4.3 + New Features

model ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 274 Views
  • 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.
  • D Offline
    D Offline
    Duy Khang
    wrote on last edited by
    #1

    how to use QStandardItemModel to load data from SQL Server to table view ?
    i can use QSqlQueryModel and QSqlTableModel, but QStandardItemModel is not.

    VRoninV 1 Reply Last reply
    0
    • D Duy Khang

      how to use QStandardItemModel to load data from SQL Server to table view ?
      i can use QSqlQueryModel and QSqlTableModel, but QStandardItemModel is not.

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @Duy-Khang said in model ?:

      i can use QSqlQueryModel and QSqlTableModel

      Those are the most straightforward tools

      how to use QStandardItemModel to load data from SQL Server to table view ?

      Run a QSqlQuery, iterate over the results and load them into the model

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • D Offline
        D Offline
        Duy Khang
        wrote on last edited by
        #3

        QStandardItemModel *itemModel = new QStandardItemModel(this);
        QSqlTableModel *model = new QSqlTableModel(this);
        model->setTable("Student");
        model->select();

        and how to use itemModel to setModel and select like model ?

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          You can't. They are 2 different classes doing 2 different things. What's your end goal here?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          2

          • Login

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