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.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.
  • R Offline
    R Offline
    rtfa
    wrote on 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
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on 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
      2
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on 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
        0
        • VRoninV VRonin

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

          R Offline
          R Offline
          rtfa
          wrote on 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
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on 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
            2
            • VRoninV VRonin

              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 last edited by
              #5

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

              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