Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7889387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:05:11+00:00 2026-06-03T06:05:11+00:00

Im a student programmer using Qt to build and application for work and I

  • 0

Im a student programmer using Qt to build and application for work and I am having some difficulty figuring out how to handle when a user has exited a Dialog without saving changes. The dialog is primarily purposed for data entry so being able to identify if changes have been made and then offering the user the option to save before quitting would be extremely usefull. I looked through Qt’s Documentation on QDialog and didn’t find anything in regards to the mode that is returned if the exit button is pressed. Having a means to just identify when the exit button is clicked is first priority. Also, being a student programmer I am also open to any ideas for best practices in regards to how I should compare before and after data. The data is entered into a table so I am guessing that I would have to make something like this

connect(some kinda exit handler, SIGNAL(clicked), this, SLOT(comparePreAndPostTable)

QVector<QString> prechanges =  everything from the table
QVector<QString> postchanges = everything from table when exit is clicked


if(prechanges != postchanges)
{
     Give oppertunity to save
}

Any assistance is appreciated! It would really be nice if Qt already had something for this!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:05:13+00:00Added an answer on June 3, 2026 at 6:05 am

    You need to override the closeEvent() method of QWidget to handle the exit button of your dialog. The documentation even give an example that strangely looks like what you are looking for:

     void MainWindow::closeEvent(QCloseEvent *event)
     {
         if (maybeSave()) {
             writeSettings();
             event->accept();
         } else {
             event->ignore();
         }
     }
    

    where maybeSave() would compare to see if anything has changed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a student programmer using QT to develop and application for work. Currently
I'm a student programmer and I am using Qt to build some GUI applications
I am a student programmer using Qt to build a GUI for work. I
I'm a student programmer and I am using Qt to build a GUI application.
I am a student programmer using Qt to build a GUI interface fro my
I am a student programmer using Qt to develop a GUI application. I am
I am currently a student programmer using Qt to build a GUI inteface at
I am a student programmer and I am using Qt to build a GUI
I am a student programmer using Qt to build a reader Table for my
Im a student programmer and Im using Qt to build a GUI for one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.