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 3957496
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:29:53+00:00 2026-05-20T02:29:53+00:00

I am having an issue trying to validate some input in QT4. I have

  • 0

I am having an issue trying to validate some input in QT4.

I have a form with 2 textEdit fields. When one field loses focus, I want it to check if the field is empty, and if so, alert the user.

Here is my code:

void newconsole::on_nameEdit_lostFocus()
{
    if (this->ui->nameEdit->text().size() < 1)
    {
        QMessageBox b;
        b.setText("Name must be longer than 0 characters.");
        b.setIcon(QMessageBox::Information);
        b.setStandardButtons(QMessageBox::Ok);
        b.show();
    }
}

void newconsole::on_fileextensionEdit_lostFocus()
{
    if (this->ui->fileextensionEdit->text().size() < 1)
    {
        QMessageBox b;
        b.setText("File extension must be longer than 0 characters.");
        b.setIcon(QMessageBox::Information);
        b.setStandardButtons(QMessageBox::Ok);
        b.show();
    }
}

My issue is that when I run the form and lose focus on the first textEdit (nameEdit) I get a MessageBox from BOTH signals. Any suggestions?

  • 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-05-20T02:29:54+00:00Added an answer on May 20, 2026 at 2:29 am

    my guess would be:

    1. your edit boxes are positioned close to each other on the form or/and next to each other in the tab order;
    2. both edit boxes are empty by default;
    3. when you’re moving focus from the empty nameEdit to the next widget which is fileextensionEdit, first message box pops up;
    4. this message box causes fileextensionEdit also to lose focus and since it’s empty a second message box gets displayed.

    hope this helps, regards

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

Sidebar

Related Questions

I'm having an issue when trying to programmatically update a DateTime field that already
I'm trying to experiment with xampp. After having some space issues, I wanted to
I'm having an issue with my regex. I want to capture <% some stuff
HI, I am trying to validate a radio button form that has an unknown
I'm having an issue trying to NOT select a tablerow with the function: $(tr).click(function(e)
I'm having an issue trying to access a web service through Delphi. I've consumed
I am having an issue trying to post a JSON string using dojo.xhrPost to
I'm having something of an issue with trying to load externally defined classes in
I am having an issue that I can't figure out. I'm trying to run
I'm having an issue with a servlet that delivers multimedia data. I'm trying to

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.