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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:10:51+00:00 2026-06-13T21:10:51+00:00

I created a QLineEdit lineEdit_X_Position input in PyQt4. I have created a input mask

  • 0

I created a QLineEdit lineEdit_X_Position input in PyQt4.

I have created a input mask with self.ui.lineEdit_X_Position.setInputMask(“00,000.00;_”).

I set the lineEdit with default value self.ui.lineEdit_X_Position.setText( format(‘6543.21’, “,.2f”) ).

When I view the UI, it shows X_Position as “6_,543.21” instead of “_6,543.21”.
I tried to set the default with self.ui.lineEdit_X_Position.setText( format(‘6543.21’, “9.2f”) ), but results = “65,43_.21”.

It gets worst when the default value is “543.21”. I get results as “54,3__.21”.

Is this a bug in QInputMask?
How to get the correct result with the QInputMask format that I want, where user can only enter numbers?

Also, if I want to validate the double results, how to use the QDoubleValidator?
The valid range is 0.00 to 10,000.00.

  • 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-13T21:10:53+00:00Added an answer on June 13, 2026 at 9:10 pm

    There is no bug in QInpuMask.

    The mask you set allows certain values to be entered in a number of different ways – all of which are equally valid. For instance, the value “543.2” could be entered by a user as 5_,_4_3._2 or __,543.2_, or _5,4__3._2, etc.

    When such a value is entered programmatically, Qt cannot guess which of the the various possiblities is the “preferred” one, and just fills in the blanks in the direction they would normally be typed. So the output you are seeing is correct, and exactly as expected.

    But given that you are trying to limit values to numbers in a certain range rather than characters in a fixed pattern, is an input mask really the right choice?

    A QDoubleSpinBox would seem to be a much better fit:

    self.spinXPosition = QtGui.QDoubleSpinBox(self)
    self.spinXPosition.setRange(0, 10000)
    self.spinXPosition.setDecimals(2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Qt, a created lineEdit shows a text using the setText() method. But the
Created Private Key & Self signed certficate in a Key Store keytool -genkey -alias
I created a JButton which has an image set as an icon representing the
Created a stored procedure in SQL 9 (2005) and have since upgraded to SQL
So currently I have code, in C++, that creates a few QLabels, a QLineEdit,
I have created for my plugin a start GUI with 3 buttons. This works
Ive created the a button $form['submit'] = array( '#type' => 'submit', '#value' => 'verify',
I created a new project using the play console now, by default I got
I have a delegate to create a QLineEdit control when you want to edit
created a very basic WS. i have LoggingHandler, Test, TestImpl, & TestPublisher. my publisher

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.