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. abandoning/reverting changes in a QDialog
Forum Updated to NodeBB v4.3 + New Features

abandoning/reverting changes in a QDialog

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

    Hi all -

    I'm writing an app that uses a QDialog to edit a row in a QAbstractItemModel. I just realized that if I make changes to some fields, then hit cancel, my changes are retained. This is probably a side effect of working directly in the model, but I can't have this. Is there a standard way of handling this?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can use QDataWidgetMapper with the submitPolicy set to ManualSubmit. That way you fully control when the changes are sent to your model.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        Oh, that's a thing of beauty.

            QDataWidgetMapper *m_mapper;
            ...
            m_mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
            ...
            if (buttonPushed == QMessageBox::Save)
            {
                // we specified manual submit policy in c'tor,
                // so we need to call submit() here.
                m_mapper->submit();
        

        Thanks, SGaist.

        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