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. QTableView inside a QDialog
Forum Updated to NodeBB v4.3 + New Features

QTableView inside a QDialog

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.9k 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.
  • S Offline
    S Offline
    schij
    wrote on last edited by
    #1

    I have a QTableView inside a dialog and a custom model attached to the view. The model changes my data when the user edits the table; however if the dialog is rejected (cancel button) I would like to restore my original data before the edits. Is there a way the model can handle that, or do I have to make a copy of my data before launching the dialog and restore it after the dialog closes?

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      It's possible to hold the "new" data in a seperate list (via model->setData) and when the dialog is closed add an extra function that validates and replaces/adds the new data to your model. Not a problem there. No idea what kind of data you have though.
      An other option might be to "copy" your original data into a new model, set the view to that model, let it all change what is needed and when the dialog is closed, check if there are any differences between the models.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • S Offline
        S Offline
        schij
        wrote on last edited by
        #3

        The data set is fairly small; I think I will go with keeping a local copy in the model and add a function to the model that will "pushData" outside. I can call this when the dialog is accepted.
        Thank you

        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