Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Why itemChanged of QStandardItemModel is invoked on all items on my model when creating the QStandardItemModel subclass



  • Hi i have model subclass m_model ( of QStandardItemModel ) it contains QStandardItem's that one of its column has setCheckable(true)
    in the subclass in the constructor i have this single/slot wired:
    @connect(m_model, SIGNAL(itemChanged(QStandardItem*)), this,
    SLOT(tree_itemChanged(QStandardItem*))); @

    why each time i create the m_model and it happen only once it iterate all the items in my model with the tree_itemChanged method ?
    i want it to be invoked only when i check/unchecked the check box.



  • bq. why each time i create the m_model and it happen only once it iterate all the items in my model with the tree_itemChanged method ?
    i want it to be invoked only when i check/unchecked the check box.

    If I 'm not wrong you have a QStandardItemModel that you use also for a tree?

    What does your SLOT tree_itemChanged do?
    You could use a condition to filter only the checked role.

    Can you elaborate a little more about the structure of your application? Do you use a proxymodel?



  • What do you do in the constructor of your subclassed model? And how and where do you populate it?

    Additionally, you can set a breakpoint in you slot and look at the call stack from where the signal was triggered.



  • Hi
    Eddy the tree_itemChanged checks if the check box checked or not and i do filter with if/else
    Volker i did see the stack , its trigger from where i iniT the object with new operator



  • So, what do you do in the constructor?



  • in my main app class i do
    @TreeViewWindowContainer* pTreeViewWindowContainer= new TreeViewWindowContainer();@

    TreeViewWindowContainer is my QStandardItemModel subclass



  • No surprise in that.

    How do you populate the model?


Log in to reply