Solved qTreeView with custom model not working.
-
Thank you for your help and your tips. i deleted this if statements from this methodes but that still not working. I already tried to use QAbstractItemModelTester but that doesn't return any problems. maybe im not using it in the good way. I also tried with the three FailureReportingMode but notihng. its like if the model is not connected to the view at all but i dont understand why. i put some qdebug in the model's methods but they are no any outputs of them from the header method.
-
@superdu Recommendation: Use the base example and modify it with the new features, do not create everything from scratch if it is the first time you try.
-
thank you for your advice but it's more or less what i did already ^^. the problem is the fact that for the official example they read text file which is different from what i'm looking for. But if you check the example you will see that my classes have same names and definitions of methodes are praticly the same than the official example. maybe you have other examples which can help me?
-
If you want another example you can have a look at this implementation but I fear it’s a bit complicated for your stage.
Can I ask why you decided to go down the hell of making a model instead of using a ready-made one (like QStandardItemModel)? -
yep, i tried standardmodel and that works but my items can store more things than strings so i did a class which inherits standard item class. after that i dont remember well why but i didn't arrived to do what i want with standard model because of type error. I foud a potential solution on internet but it was not elegant. So i thought about developping my own model for learn and for have the possibility to complexify the widget in the future . thank you for your example by the way
-
QStandardItem can handle all data types, take a look at the setData method.
-
can i store classes as QVariant?
-
-
-
thank you i will try that.