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. compare indexes of selected model and the model

compare indexes of selected model and the model

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 519 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.
  • U Offline
    U Offline
    user4592357
    wrote on last edited by
    #1

    i have a tree view and wanna know whether the first index is selected.
    if i do

    auto lst = TreeView->selectionModel()->selectedIndexes();
    if (lst.front() == TreeView->model()->index(0, 0))
    {
         // doesn't reach here because operator== of QModelndex compares the corresponding models too
    }
    

    what can i do?

    JonBJ 1 Reply Last reply
    0
    • U user4592357

      i have a tree view and wanna know whether the first index is selected.
      if i do

      auto lst = TreeView->selectionModel()->selectedIndexes();
      if (lst.front() == TreeView->model()->index(0, 0))
      {
           // doesn't reach here because operator== of QModelndex compares the corresponding models too
      }
      

      what can i do?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @user4592357
      Does this work?

      TreeView->selectionModel()->isSelected( TreeView->model()->index(0, 0) )
      
      U 1 Reply Last reply
      3
      • JonBJ JonB

        @user4592357
        Does this work?

        TreeView->selectionModel()->isSelected( TreeView->model()->index(0, 0) )
        
        U Offline
        U Offline
        user4592357
        wrote on last edited by user4592357
        #3

        @JonB
        it didn't work for me :(
        EDIT: i used isRowSelected() and that worked

        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