Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. passing model class
Qt 6.11 is out! See what's new in the release blog

passing model class

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 546 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.
  • O Offline
    O Offline
    Omid
    wrote on last edited by VRonin
    #1

    Hi there,

    I have a QStandardItemModel model (i.e,: QStandardItemModel *model;) made in mainwindow header code. I am passing it to a class SetDefault to put some default values in the model class. To do so, in mainwindow code I pass "&mode "and in class SetDefault get it as argument SetDefault (QStandardItemModel **_model). Next I set values in the passed model in such a way: (*_model)->setData(index,dat);
    Code runs, however, when i get the model back in mainwindow no changes was made to the model class! I have checked and the memory address of model class in the mainwindow is the same as the memory address of " *_model " in SetDefault class. But the model doesn't show changes after being back in the mainwindow.

    Any help is appreciated.

    Omid

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

      Hi and welcome to devnet,

      Please share the code where you create the model as well as the one you are using to modify 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
      3
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        why passing a double pointer instead of just the QStandardItemModel* ?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        3

        • Login

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