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. How to insert data rows to QProxyModel?
QtWS25 Last Chance

How to insert data rows to QProxyModel?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 3.2k 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.
  • Z Offline
    Z Offline
    zither
    wrote on last edited by
    #1

    @this->beginInsertRows(QModelIndex(),this->rowCount(),List.length());
    for (int i=0;i<List.length();i++){
    this->insertRow(this->rowCount(),QModelIndex());
    this->setData(this->index(this->rowCount(),0),QString("TEST"),Qt::DisplayRole);}
    this->endInsertRows();@

    I can't insert with above code..
    How can I insert QList<QStandardItem*> List into that QProxyModel?
    Or need another QList<????*> List ?

    Thanks

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      Hi zither,

      If the proxy model is the QSortFilterProxyModel it will call the source modles functions for that. If the source model does not support inserting rows, it will do nothing.

      Or do you have a custom implemented proxy model? then perhaps, it's missing some implementation...

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zither
        wrote on last edited by
        #3

        Hi Gerolf,

        I'm making custom QProxyModel which source Model is QSqlQueryModel, I would like to add new rows to QProxyModel which will show to QListView.
        @QSqlQueryModel -> QProxyModel ->QListView;@
        How can I insert new rows for that?

        Thanks

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          insertRows empty implementation does nothing. You have to do the insert pon your own, so e.g. call the source models insertRow function instead of the base implementation.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zither
            wrote on last edited by
            #5

            My Source Model is QSqlQueryModel which is read-only..

            So, I have to change type of my source Model?
            Is there any model which can handle one data source & inserting of data via Model?

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              What do you try to achieve?

              Do you just want to insert data temporarily? then QProxyModel is a a possibility. But you have to handle it on your own. There is no default model for such things. You have abstract models (only base classes), proxy models (QSFPM) which do not implement inserting data by default, SQL models which allow inserting data but that is only possible if the model is not readonly.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                zither
                wrote on last edited by
                #7

                I made a search method for SQLite Database.
                So, I choose QSqlQueryModel as it source. Then, I need to insert some XML data from another at the same time. So, I have to insert new rows to that Model which link to ModelView.

                Plz help me to pass that problem...

                Thanks

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  Why are you starting a new topic on that? You have several topics on this already. Please stick to one topic for one question.

                  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