This causes three things to happen: the table instantiates a widget for editing the value and places it in the space occupied by the cell, calls data() on the model using the EditRole to get the cell's value in editable form, then sets that value into the editor widget and sets input focus to it. The Qt Model / View architecture works roughly like this when the view is some sort of table view: Last edited by drmacro 3rd April 2017 at 20:24. "Your implementation doesn't return anything." So, self.arraydata is not the model data that is displayed in the table? #Refresh tableview qt code"With the code as you've written it, you have no way to change existing elements in the model." (Obviously not what I'd set it to for REAL use, though, here again, I'm not sure what other role I might want.) In this case, I didn't bother checking it because I'm calling and it is set to 0. "is it always with a Qt.DisplayRole value for the role" The doc ( ) doesn't, at least to me, indicate that it gets called by native code. #Refresh tableview qt how to"why is your code bothering to call it at all?"īecause I'm trying to figure out how to call it correctly and have had little success after reading docs, trying examples, and searching the web until my eyes are dry and blurry. #Refresh tableview qt updateThe default implementation returns false, so perhaps that is why the view update isn't occurring.Well, I'll reply, not necessarily in order. Your implementation doesn't return anything. In C++, the setData() method is supposed to return "true" if the update was successful, "false" if not. The default implementation returns false, so perhaps that is why the view update isn't occurring. With the code as you've written it, you have no way to change existing elements in the model. Which begs the question - if your code is calling setData() and then ignoring everything that is passed as argument except self, why is your code bothering to call it at all? If what you want to do is to extend the array, then write yourself a custom method for your model that does that, don't override and misuse a standard model method. Likewise, you do not check that "index" is valid indeed, you ignore index entirely - what is index is invalid or pointing to an already existing element of arrayData? Your code seems to assume that it's always going to point beyond the end of the array, so you have to extend it.Īnd you ignore the "value" argument as well. Why are you ignoring the "role" in the setData() call? Who is calling setData(), and with what value(s)? Is it always your code, and is it always with a Qt.DisplayRole value for the role? If not, then you need to check that the role = Qt.DisplayRole and if not, do nothing. If orientation = QtCore.Qt.Horizontal and role = QtCore.Qt.DisplayRole: Self.createIndex(self.rowCount(None),lumnCount(None)))ĭef headerData(self, col, orientation, role): QtCore.QAbstractTableModel._init_(self, parent) #Refresh tableview qt registrationIf you have any problems with the registration process or your account login, please contact us.Ĭlass MyTableModel(QtCore.QAbstractTableModel):ĭef _init_(self, datain, headerdata, parent=None): Registration is fast, simple and absolutely free so please, join our community today! By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. If you are looking for information about Qt related issue - register and post your question. Over 90 percent of questions asked here gets answered. Qt Centre is a community site devoted to programming in C++ using the Qt framework. Select the forum that you want to visit from the selection below. Tabview update after the model data changesīefore you can post: click the register link above to proceed.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |