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. Loading two columns at start in QColumnView

Loading two columns at start in QColumnView

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.3k 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.
  • R Offline
    R Offline
    rtfa
    wrote on 24 Feb 2017, 13:50 last edited by
    #1

    I would like to load two columns at start in QColumnView. In the first column with First level of rows. Second column with a particular row's children with a particular row being selected[ie., highlighted].

    I tried calling the createColumn with the model index of the row in first column. But it didn't work. Is there any way? However in tree view it looks straight forward with QTreeView.expand(QModelIndex). Any help is much appreciated.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 24 Feb 2017, 14:40 last edited by
      #4

      Had a peak at the sources, the solution is:
      columnView->selectionModel()->setCurrentIndex(index,QItemSelectionModel::Current|QItemSelectionModel::Select);

      Not well documented, I agree

      "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

      R 1 Reply Last reply 26 Feb 2017, 18:14
      2
      • V Offline
        V Offline
        VRonin
        wrote on 24 Feb 2017, 13:55 last edited by
        #2

        have you tried something like columnView->selectionModel()->select(index,QItemSelectionModel::ClearAndSelect);?

        "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

        R 1 Reply Last reply 24 Feb 2017, 14:10
        0
        • V VRonin
          24 Feb 2017, 13:55

          have you tried something like columnView->selectionModel()->select(index,QItemSelectionModel::ClearAndSelect);?

          R Offline
          R Offline
          rtfa
          wrote on 24 Feb 2017, 14:10 last edited by
          #3

          @VRonin Yes, tried this already. It selects the row[with grey background - not with blue background] but the next column is not loaded.

          Even tried invoking the clicked() event on QColumnView with the desired index. It also failed.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            VRonin
            wrote on 24 Feb 2017, 14:40 last edited by
            #4

            Had a peak at the sources, the solution is:
            columnView->selectionModel()->setCurrentIndex(index,QItemSelectionModel::Current|QItemSelectionModel::Select);

            Not well documented, I agree

            "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

            R 1 Reply Last reply 26 Feb 2017, 18:14
            2
            • V VRonin
              24 Feb 2017, 14:40

              Had a peak at the sources, the solution is:
              columnView->selectionModel()->setCurrentIndex(index,QItemSelectionModel::Current|QItemSelectionModel::Select);

              Not well documented, I agree

              R Offline
              R Offline
              rtfa
              wrote on 26 Feb 2017, 18:14 last edited by
              #5

              @VRonin That's Gr8. Works like a charm. Thanks much :)

              1 Reply Last reply
              0

              4/5

              24 Feb 2017, 14:40

              • Login

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