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

  • SEARCH
  • Home
  • 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 8470119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:25:38+00:00 2026-06-10T16:25:38+00:00

I have a QLineEdit which I use to get a double. But is there

  • 0

I have a QLineEdit which I use to get a double. But is there a more suitable way to get it? Here it is my code.

ui->lineEdit->setValidator(new QIntValidator(this));

QString XMAX=ui->lineEdit->text();
double xmax=XMAX.toDouble();
  • 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-10T16:25:40+00:00Added an answer on June 10, 2026 at 4:25 pm

    The canonical way to input a double is of course to use a QDoubleSpinBox.

    If you insist on using a QLineEdit, you should use it together with a QDoubleValidator instead of your QIntValidator. I would just add a sanity check that something has been entered into the edit field:

    double xmax;
    if (ui->lineEdit->text()->isEmpty())
        xmax = numeric_limits<double>::quiet_NaN();
    else
        xmax = ui->lineEdit->text().toDouble();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have the ability to use superscripts asnd subscripts in a QLineEdit
First I'll show the code. class XLineEdit(QtGui.QLineEdit): '''QLineEdit with clear button, which appears when
Is there any standard way to create drop-down menu from QLineEdit without QCompleter? For
I have a QLineEdit, on which I have set a QRegExpValidator, that allows the
Well, i have this app which has a lot o lineEdit widgets on it
I have two widgets, one arbitrary (usually a QLineEdit), and one QLabel which displays
I have two classes(MyWidget,ViewContact). In MyWidget, there is a QLineEdit and QListWidget. The contents
So currently I have code, in C++, that creates a few QLabels, a QLineEdit,
I have a main PyQt window, from which I need to get a string
I have a QLineEdit widget in my menubar which shows the text search by

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.