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 select previous row
Forum Updated to NodeBB v4.3 + New Features

QTableWidget select previous row

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 641 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.
  • P Offline
    P Offline
    panch
    wrote on last edited by panch
    #1

    Hi all,

    I have a question regarding a QTableWidget which has been populated on runtime. The user can click each row and edit data representing this particular row.
    If the user does not save the data after editing, and selects another row - then the user is prompted if he is sure he wants to discard the changes and change selection.

    If he selects NO - then the previous row should be highlighted again - but I cannot make this work.
    I have tried reacting on the slot currentItemChanged, and in this one call the following:

    ui.tableInstructions->BlockSignals(true);
    ui.tableInstructions->setItemSelected(current, false);
    ui.tableInstructions->setItemSelected(previous, true);
    ui.tableInstructions->BlockSignals(false);
    

    Since when you enter the function, the current one is the one that you DONT want to change to - you want to keep the previous one the current selection.
    No matter what I do, I cannot get the previous row highlighted.

    Any help?

    VRoninV 1 Reply Last reply
    0
    • P panch

      Hi all,

      I have a question regarding a QTableWidget which has been populated on runtime. The user can click each row and edit data representing this particular row.
      If the user does not save the data after editing, and selects another row - then the user is prompted if he is sure he wants to discard the changes and change selection.

      If he selects NO - then the previous row should be highlighted again - but I cannot make this work.
      I have tried reacting on the slot currentItemChanged, and in this one call the following:

      ui.tableInstructions->BlockSignals(true);
      ui.tableInstructions->setItemSelected(current, false);
      ui.tableInstructions->setItemSelected(previous, true);
      ui.tableInstructions->BlockSignals(false);
      

      Since when you enter the function, the current one is the one that you DONT want to change to - you want to keep the previous one the current selection.
      No matter what I do, I cannot get the previous row highlighted.

      Any help?

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @panch said in QTableWidget select previous row:

      The user can click each row and edit data representing this particular row.
      If the user does not save the data after editing

      How does it not save it? How are you implementing the editor?

      "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

      1 Reply Last reply
      0
      • P Offline
        P Offline
        panch
        wrote on last edited by
        #3

        I have a save-button that the user has to press if he wants to save the changes. I'm not using a model view.

        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