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. Qtablewidget set Focus to a row and select the value?
QtWS25 Last Chance

Qtablewidget set Focus to a row and select the value?

Scheduled Pinned Locked Moved General and Desktop
setdataqt4selectionlinuxqtablewidget
2 Posts 2 Posters 7.7k 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.
  • A Offline
    A Offline
    Adrianos
    wrote on 27 Mar 2015, 09:29 last edited by Adrianos
    #1

    Hello,

    i wanna change the value in a QtTableWidget and press enter. After i changed the value and pressed Enter, i wanna select(mark blue) the changed row. The Problem is i have an example code that makes what i want, but after view clicks they select all the rows from last row to the clicked row. I must click Escape Key to get out from this proble.

    Where ist the Problem? I think that the Problem is the Method.. Here ist the Code:

    void parameterChangedDelegate(QTableWidgetItem *item)
    {

        int row = item->row();
        QModelIndex ninx = model()->index(row,1);
        selectionModel()->select(ninx, QItemSelectionModel::Select);
        setCurrentIndex(ninx);
       setFocus();
       edit(ninx);
    

    }

    P 1 Reply Last reply 27 Mar 2015, 12:06
    0
    • A Adrianos
      27 Mar 2015, 09:29

      Hello,

      i wanna change the value in a QtTableWidget and press enter. After i changed the value and pressed Enter, i wanna select(mark blue) the changed row. The Problem is i have an example code that makes what i want, but after view clicks they select all the rows from last row to the clicked row. I must click Escape Key to get out from this proble.

      Where ist the Problem? I think that the Problem is the Method.. Here ist the Code:

      void parameterChangedDelegate(QTableWidgetItem *item)
      {

          int row = item->row();
          QModelIndex ninx = model()->index(row,1);
          selectionModel()->select(ninx, QItemSelectionModel::Select);
          setCurrentIndex(ninx);
         setFocus();
         edit(ninx);
      

      }

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 27 Mar 2015, 12:06 last edited by
      #2

      @Adrianos How about using setSelected ? Since you already have the QTableWidgetItem .

      157

      1 Reply Last reply
      0

      1/2

      27 Mar 2015, 09:29

      • Login

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