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. How to get column Count if i have only the QModelIndex
Forum Updated to NodeBB v4.3 + New Features

How to get column Count if i have only the QModelIndex

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 4.3k 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
    umen242
    wrote on last edited by
    #1

    Hi
    i like to get the column count of selected row , now i have slot function that connected to the click() signal
    i can get the selected QStandardItem using QStandardItemModel itemFromIndex method .
    but how can i get the count of the column's in the selected row ?
    also how can i get the selected row index ?
    Thanks

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      @model->columnCount(index.parent());@

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

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

      1 Reply Last reply
      0
      • U Offline
        U Offline
        umen242
        wrote on last edited by
        #3

        Thanks allot , just one problem ... how do i know the selected row index ?
        ):

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

          if you only have the index, ypou can also write:

          @
          index.model()->columnCount(index.parent());
          int nRow = index.row();
          @

          A look to the documentation would help: "QModelIndex":http://doc.qt.nokia.com/4.7/qmodelindex.html

          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

          • Login

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