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 ensure all models updated before accepting a QDialog
Forum Updated to NodeBB v4.3 + New Features

How to ensure all models updated before accepting a QDialog

Scheduled Pinned Locked Moved General and Desktop
qdialogqabstractitemmo
2 Posts 2 Posters 1.3k 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.
  • B Offline
    B Offline
    bsomervi
    wrote on 6 Apr 2015, 12:41 last edited by bsomervi 4 Jun 2015, 13:15
    #1

    Hi,

    I have an issue with a QDialog, it has a QTableView using a custom model and if the user is editing a table field and doesn't leave the field or hit ENTER the edits are not reflected in the override of QDialog::accept() I have (called by signal/slot from "Ok" button clicked signal) until the super class QDialog::accept() is called. I don't want to call QDialog::accept() until I have validated the model contents so I appear to have a "Chicken & Egg" problem here.

    How do I make sure any active item delegate completes and the model setData method is called before I call QDialog::accept()?

    I would have though that clicking the "Ok" button would have been enough as that surely takes the focus away from the active item delegate but debug trace shows that the setData for the edited value on the underlying model is not called until QDialog::accept() is invoked.

    TIA
    Bill.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 6 Apr 2015, 13:29 last edited by
      #2

      Something like this should do the trick:

      void MyDialog::accept() {
         stuff->setFocus(); //to move focus away from the table or any delegate
         if( /* do any data validation */)
            QDialog::accept(); //call base implementation only if everything is ok
      }
      
      1 Reply Last reply
      0

      1/2

      6 Apr 2015, 12:41

      • 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