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. QTableView - some cells and column headers not editable
QtWS25 Last Chance

QTableView - some cells and column headers not editable

Scheduled Pinned Locked Moved General and Desktop
19 Posts 4 Posters 12.4k 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.
  • P Offline
    P Offline
    Psychonaut
    wrote on last edited by
    #6

    bq. What do you want happening when the header is clicked?

    The column should sort (what works for those headers, whose cells are completely editable)

    Is there a way to force the selection behavior? So I can click or sort the column?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Psychonaut
      wrote on last edited by
      #7

      Could following be a solution?
      I just create a dummy row, which is completely empty and grayed out. Additionally it can't be sorted. How can I implement it? Maybe with subclassing? But where do I start?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #8

        Sounds like a work-around hack, and not a solution. I would start to try and find out why your cells are not editable in the first place. Use a debugger to step into the code, and find out what happens...

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Psychonaut
          wrote on last edited by
          #9

          Hello,
          I cant locate the error. What do you mean by "use a debugger to step into the code"? How can I watch the changes made in tableview using a debugger?
          Don't know what to do now. It's very strange that only the first row is affected.

          Edit: Which part of the code may be interesting regarding the changes in tableview?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #10

            Just set a breakpoint in the model you use at one or more appropriate points (the data() method comes to mind), and run using a debugger (F5 when using QtCreator). It might also help if you create a minimum but compilable example that shows the problem and that you offer for download, so others can try to re-produce the problem.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Psychonaut
              wrote on last edited by
              #11

              Where can I upload the minimized project?

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #12

                Where ever you like. I usually use my public Dropbox folder when I upload stuff for this forum, but you may also use any other service you fancy. Qt DevNet does not provide an uploading service itself.

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Psychonaut
                  wrote on last edited by
                  #13

                  I created a minimized project:
                  http://www.sendspace.com/file/sgb6mk

                  Edit: Just put it in /Qt/Sql example folder

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Psychonaut
                    wrote on last edited by
                    #14

                    After creating a completely new database with sqlite3 command line tool with new tables etc. using sqlitebrowser the shock: same error! I don't know why this problem occurs?!
                    Edit: I created a new project and tried also instead of using QSqlRelationalTableModel to use just TableModel but there's no difference.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on last edited by
                      #15

                      OK, I managed to build your example, and confirm your issue. I'll try to see if I can find what is going wrong.

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        andre
                        wrote on last edited by
                        #16

                        I am completely at a loss. Even if I further simply your sample (use a QSqlQueryModel instead of a QSqlRelationalTableModel), I get the same behavior you described. Very, very strange indeed. I would have expected the flags() implementation to be the problem, but it seems that it isn't even implemented until the QAbstractItemModel.

                        I tried to see what flags are returned by the model for each index, and that looks fine to me. According to this code, every index should be enabled and selectable:
                        @

                        void Window::getModelIndex()
                        {
                        int rows = tableView->model()->rowCount();
                        int columns = tableView->model()->columnCount();
                        for (int row(0); row<rows; ++row) {
                        for (int col(0); col<columns; ++col) {
                        QModelIndex idx = tableView->model()->index(row, col);
                        qDebug() << "r:" << row << "c:" << col << "valid:" << idx.isValid() << "flags:" << idx.flags();
                        }
                        }
                        }
                        @

                        Why those cells refuse to be selected anyway is beyond me.

                        I think it is time to file a bug report.

                        1 Reply Last reply
                        0
                        • P Offline
                          P Offline
                          Psychonaut
                          wrote on last edited by
                          #17

                          What is the result of the bug report? How long will it take to fix that problem?

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

                            it depends on the problem complexity etc...
                            There is no time frame for such things.

                            If you need fast responses and fixes, you need a commercial license and support. Otherwise you could also fix it and create a merge request on www.gitorious.org

                            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
                            • A Offline
                              A Offline
                              andre
                              wrote on last edited by
                              #19

                              [quote author="Psychonaut" date="1305785662"]What is the result of the bug report? How long will it take to fix that problem?[/quote]

                              That depends on how important is it deemed to be (by the maintainer of that piece of code), other priorities, and how complex the issue is, as well as how well documented and easy to reproduce the issue is. That is: there is no fixed time frame. Some bugs are never solved, some the same day.

                              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