Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Solved Auto Generating Model code

    General and Desktop
    modeldata
    3
    7
    1395
    Loading More Posts
    • 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.
    • clogwog
      clogwog last edited by

      Hi,

      I have just gone through a simple ToDo list tutorial (https://www.youtube.com/watch?v=9BcAYDlpuT8) that uses QML and stores the model in C++

      There seems to be a lot of 'gotcha's that need to be implemented for each model in C++ (overriding QAbstractListModel). I guess once you do a few it gets easier.

      My Question: Is there an Code generator around that you give an IDL to that can do all this tedious work for you ? (In the same way that DJango does this perhaps ?)

      thanks,
      tom

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        AFAIK, no, there's no such tool.

        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 Reply Quote 2
        • clogwog
          clogwog last edited by

          thanks..
          if you haven't seen it i bet it doesn't exist

          1 Reply Last reply Reply Quote 0
          • clogwog
            clogwog last edited by

            Just found Thomas Boutroue's macro's that look after a lot of the gotcha's

            https://www.youtube.com/watch?v=96XAaH97XYo

            very interesting . i'll try the same todo list with this and report back

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              The fact that I'm not aware of such a tool doesn't mean it doesn't exist. There are lots of stuff going on around Qt ;)

              IIRC, he has several libraries and helpers that might be of interest, thanks for the reminder !

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              clogwog 1 Reply Last reply Reply Quote 0
              • clogwog
                clogwog @SGaist last edited by

                Oh wow. I just re-implemented the todo list example with heaps less code.
                i think i'll keep using this.

                now see if i can also use QuickFlux in the same application....
                (third try but i usually get lost towards the end of the tutorial )

                1 Reply Last reply Reply Quote 0
                • V
                  VRonin last edited by

                  What I usually feel like suggesting is not to subclass the model at all. use QStandardItemModel only via the QAbstractItemModel interface (you can force yourself by declaring QAbstractItemModel* model =new QStandardItemModel(parent);).

                  If the model's performance is really a drag for your application you can go the length and implement a model subclass (with all its gotchas) changing just 1 line in your existing code

                  "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 Reply Quote 1
                  • First post
                    Last post