Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [solved]QAbstractListModel - update data in table view [linux]
Forum Updated to NodeBB v4.3 + New Features

[solved]QAbstractListModel - update data in table view [linux]

Scheduled Pinned Locked Moved Mobile and Embedded
29 Posts 3 Posters 13.1k 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.
  • S Offline
    S Offline
    s_z_p
    wrote on last edited by
    #21

    Model view approach is needed for let's say full version of the script.

    I think I get your point about string. Let me check that.

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

      The signal will just tell you that the file has changed, it will not reload the content for you. You'll have to parse the file again and update stockdata with what you just read from it

      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
      • S Offline
        S Offline
        s_z_p
        wrote on last edited by
        #23

        One more thing.
        file_check = QtCore.QFileSystemWatcher(['/home/user/Desktop/plik.txt'])
        file_check only checks if file was changed if was:

        file_check.fileChanged.connect(resetItems)
        it sends signal to 'resetItems' and 'resetItems' should reload data, true?
        and I have to find a way how accept the string parameter emitted by fileChanged..

        1 Reply Last reply
        0
        • S Offline
          S Offline
          s_z_p
          wrote on last edited by
          #24

          Is it better ? but I have got error like that:
          AttributeError: 'StockListModel' object has no attribute 'beginResetModel'

          @def init(self, stockdata = [], parent = None):
          QtCore.QAbstractListModel.init(self, parent)
          self.stockdata = stockdata
          self.file_check = QtCore.QFileSystemWatcher(['/home/user/Desktop/file.txt'])
          self.file_check.fileChanged.connect(self.resetItems)

              def getItems(self):
                 return stockdata
          
              @QtCore.pyqtSlot(str)
              def resetItems(self, path):
                 self.beginResetModel()
                 ....
          

          @

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

            You have to the data reloading yourself. Like in your main function.

            As for beginResetModel I don't know why it's saying that

            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
            • S Offline
              S Offline
              s_z_p
              wrote on last edited by
              #26

              I cannot find a solution for this error.
              @SGaist, writing "reloading data" do you mean file with data?

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

                Yes, that's what I mean. On you program startup you are reading that file and put it's content in the stockdata variable. When the QFileSystemWatcher triggers, you must do that parsing again.

                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
                • S Offline
                  S Offline
                  s_z_p
                  wrote on last edited by
                  #28

                  Finally solved. 'beginResetModel', 'end...' and 'self.stockdata' in 'resetItems' are not needed. It can be done without it. Thank you for support.

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

                    You're welcome !

                    Since you have it working now, please update the thread title prepending [solved] so that other forum users may know a solution has been found :)

                    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

                    • Login

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