Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to decouple a QStandardItemMode from a QTableView?
Qt 6.12 LTS is out! See what's new in the release blog

How to decouple a QStandardItemMode from a QTableView?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 435 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.
  • L Offline
    L Offline
    Lee908
    wrote on last edited by
    #1

    Hi,

    How to decouple a QStandardItemMode from a QTableView? I tried it as below:

    myTableView->setModel(myModel);
    ...
    myTableView->setModel(NULL);  //decoupled here
    ...
    myTableView->setModel(myModel);  //reset model after some work is done.
    

    It caused a strange phenomenon: After reset the model, the signal QStandardItemModel::itemchanged is always triggered twice when I edit the model data. I'm confused... Anyone can give me a hint please? Many thanks.

    JonBJ 1 Reply Last reply
    0
    • L Lee908

      Hi,

      How to decouple a QStandardItemMode from a QTableView? I tried it as below:

      myTableView->setModel(myModel);
      ...
      myTableView->setModel(NULL);  //decoupled here
      ...
      myTableView->setModel(myModel);  //reset model after some work is done.
      

      It caused a strange phenomenon: After reset the model, the signal QStandardItemModel::itemchanged is always triggered twice when I edit the model data. I'm confused... Anyone can give me a hint please? Many thanks.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Lee908
      setModel(nullptr) should indeed remove the QTableView from having slots attached to the QStandardItemModel, and setModel(myModel) again should set it to receive signals anew, without "doubling". However, "the signal QStandardItemModel::itemchanged is always triggered twice": attaching a view to a model connects its slots to model signals, it should not have anything to do with how many times any signals are triggered, which is a model-only thing.

      Can you reproduce this behaviour in a small, standalone sample?

      1 Reply Last reply
      1

      • Login

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