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. QTableWidget populating
Forum Updated to NodeBB v4.3 + New Features

QTableWidget populating

Scheduled Pinned Locked Moved General and Desktop
11 Posts 5 Posters 8.0k 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.
  • A Offline
    A Offline
    awood969
    wrote on last edited by
    #2

    Oh! Never mind solved it myself! Thanks Anways :-D

    I'm only asking as I'm stupid :-)

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vcsala
      wrote on last edited by
      #3

      You should build a model inherited from QAbstractTableModel and set it as a basemodel for the QTableWidget.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #4

        If you use models, you should use QTabelView, not QTableWidget. And from my point of view, the model-view approach is much better than the QTableWidget approach.

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vcsala
          wrote on last edited by
          #5

          AFAIK QTableWidget inherits QTableView

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dangelog
            wrote on last edited by
            #6

            [quote author="VCsala" date="1292523877"]AFAIK QTableWidget inherits QTableView[/quote]

            Indeed it does. You can consider the QWidget classes to be exactly like the QView classes, but with a builtin model (which closely resembles QStandardItemModel) and helper classes to manage this models (the QWidgetItem classes). Using a custom model with the QWidget classes is pointless, since you won't be able to use their helper classes to manage the model.

            [quote author="VCsala" date="1292521276"]You should build a model inherited from QAbstractTableModel and set it as a basemodel for the QTableWidget.[/quote]

            s/QTableWidget/QTableView/, see above.

            Software Engineer
            KDAB (UK) Ltd., a KDAB Group company

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vcsala
              wrote on last edited by
              #7

              Guys, you win :) Anyhow, thanks for the correction, I am still have a lot to learn.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #8

                But the *widget classes with their helpers and standard models are for the general purpos and therefore not optimized. So, in fact, if you have a growing app, it might happen, that you need more code in the end then with a custom model / view approach.

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #9

                  The decision is not so easy. We use both the QxxWidgets and the QxxViews in our code. Sometimes it's more convenient to have a QxxWidgetItem subclass to add the functionality, especially if you only want to add a small improvement and are satisfied with the standard implementation for the rest. Although I must admit that we generally do not have big amounts of data in the Widgets, so speed and space optimization is not a big issue for us.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on last edited by
                    #10

                    Ok, so there's a big difference, we normally have much data or possibly much data, as we visualize industry values....

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dangelog
                      wrote on last edited by
                      #11

                      !http://imgs.xkcd.com/comics/donald_knuth.png!

                      Software Engineer
                      KDAB (UK) Ltd., a KDAB Group company

                      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