Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Table creation with ListView
Forum Updated to NodeBB v4.3 + New Features

Table creation with ListView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
16 Posts 3 Posters 2.5k 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.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #2

    How do you separate data in different columns?

    "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
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #3

      I prefer you build your own model on C++ side & expose the model to QML side. Use delegate to format your data. How to expose the model & view in list view ? Refer the GIT

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      1
      • B Offline
        B Offline
        Babs
        wrote on last edited by
        #4

        [0_1546446844578_canbusqml.h](Uploading 100%) ![0_1546446682716_Capture.PNG
        I want to use a ListView . This image shows my QStringList content at one index. The first element represent the identifier of the CAN message,the second the lenght and third the payload of the message. I want to seperate each one of that elemeents in different columns.

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #5

          Should be something like: https://pastebin.com/Vetsi5z7

          "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
          1
          • dheerendraD Offline
            dheerendraD Offline
            dheerendra
            Qt Champions 2022
            wrote on last edited by
            #6

            Do you need to QML listView or QTableView is enough ? As @VRonin suggested, you can just use the QTableView along with QStandardModel to display it. If you want to display in QML, suggest you to use your own custom model.

            Dheerendra
            @Community Service
            Certified Qt Specialist
            http://www.pthinks.com

            B 1 Reply Last reply
            1
            • dheerendraD dheerendra

              Do you need to QML listView or QTableView is enough ? As @VRonin suggested, you can just use the QTableView along with QStandardModel to display it. If you want to display in QML, suggest you to use your own custom model.

              B Offline
              B Offline
              Babs
              wrote on last edited by
              #7

              @dheerendra I can't use QTableView because i'm working with qt 5.11 and developping mobile apps. In 5.11 version QTableView is only available for Desktop apps.

              1 Reply Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #8

                https://doc-snapshots.qt.io/qt5-dev/qml-qtquick-tableview.html

                "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

                B 1 Reply Last reply
                0
                • dheerendraD Offline
                  dheerendraD Offline
                  dheerendra
                  Qt Champions 2022
                  wrote on last edited by
                  #9

                  You are using the QML. You need to write your own model in C++ side to expose the data to qml. Use either ListView or TableView to display the data.

                  Dheerendra
                  @Community Service
                  Certified Qt Specialist
                  http://www.pthinks.com

                  1 Reply Last reply
                  0
                  • VRoninV VRonin

                    https://doc-snapshots.qt.io/qt5-dev/qml-qtquick-tableview.html

                    B Offline
                    B Offline
                    Babs
                    wrote on last edited by
                    #10

                    @VRonin Thank you
                    I'll try to use Tableview with custom model. Can i have an idea of how to seperates my data in identifiers payload and length colums?
                    The second problems is that i'm returning a List of QCanBusFrame. This type of data can't be displayed easily

                    VRoninV 1 Reply Last reply
                    0
                    • B Babs

                      @VRonin Thank you
                      I'll try to use Tableview with custom model. Can i have an idea of how to seperates my data in identifiers payload and length colums?
                      The second problems is that i'm returning a List of QCanBusFrame. This type of data can't be displayed easily

                      VRoninV Offline
                      VRoninV Offline
                      VRonin
                      wrote on last edited by
                      #11

                      Can i have an idea of how to seperates my data in identifiers payload and length colums?

                      @VRonin said in Table creation with ListView:

                      Should be something like: https://pastebin.com/Vetsi5z7


                      This type of data can't be displayed easily

                      https://wiki.qt.io/How_to_Use_a_Custom_Class_in_C%2B%2B_Model_and_QML_View

                      "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

                      B 1 Reply Last reply
                      0
                      • VRoninV VRonin

                        Can i have an idea of how to seperates my data in identifiers payload and length colums?

                        @VRonin said in Table creation with ListView:

                        Should be something like: https://pastebin.com/Vetsi5z7


                        This type of data can't be displayed easily

                        https://wiki.qt.io/How_to_Use_a_Custom_Class_in_C%2B%2B_Model_and_QML_View

                        B Offline
                        B Offline
                        Babs
                        wrote on last edited by
                        #12

                        @VRonin Last question.
                        Where should I seperate my data into frames? In main file or in model file?

                        1 Reply Last reply
                        0
                        • VRoninV Offline
                          VRoninV Offline
                          VRonin
                          wrote on last edited by
                          #13

                          It's really up to you.
                          I would create the QCanBusFrame outside the model and then load it but it's really just a matter of flavour

                          "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
                          1
                          • B Offline
                            B Offline
                            Babs
                            wrote on last edited by
                            #14

                            const QRegularExpression partsRegExp(R"^\s*(\S+)\s+[(\S+)]\s+(.+?)\s*$");
                            from your link, this line code generate an error in QT. It says: Invalid character ''....................

                            1 Reply Last reply
                            0
                            • VRoninV Offline
                              VRoninV Offline
                              VRonin
                              wrote on last edited by
                              #15

                              old compiler?
                              You can double all the \ and remove the R at the beginning

                              "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

                              B 1 Reply Last reply
                              1
                              • VRoninV VRonin

                                old compiler?
                                You can double all the \ and remove the R at the beginning

                                B Offline
                                B Offline
                                Babs
                                wrote on last edited by
                                #16

                                @VRonin Thank you.
                                I seperated my data successfuly
                                You can mark it resolved

                                1 Reply Last reply
                                0

                                • Login

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