Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Pyside QLineEdit entering data from right-to-left
Forum Updated to NodeBB v4.3 + New Features

Pyside QLineEdit entering data from right-to-left

Scheduled Pinned Locked Moved Unsolved Language Bindings
3 Posts 2 Posters 1.1k Views
  • 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.
  • J Offline
    J Offline
    Joel Graff
    wrote on last edited by
    #1

    So, I have a somewhat unique data-entry need. It's not really unique, but I can't seem to find a way to implement it in PySide. Specifically, I have a field that is filled with a floating-point number. It takes the form of "00009+99.00"

    Because the first four leading values are optional, I'd rather data entry began at the right and was pushed to the left. That is, the cursor would remain fixed at right and as the user entered data, it would expand leftward. Is there a way to do that without trying to concoct a Python function that gets called when the text gets changed?

    aha_1980A 1 Reply Last reply
    0
    • J Joel Graff

      So, I have a somewhat unique data-entry need. It's not really unique, but I can't seem to find a way to implement it in PySide. Specifically, I have a field that is filled with a floating-point number. It takes the form of "00009+99.00"

      Because the first four leading values are optional, I'd rather data entry began at the right and was pushed to the left. That is, the cursor would remain fixed at right and as the user entered data, it would expand leftward. Is there a way to do that without trying to concoct a Python function that gets called when the text gets changed?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Joel-Graff your example does not look like valid float number.

      Do you need exponential format? I'm not sure, if QDoubleSpinbox provides that, otherwise it would be first choice for that task. For the line edit, you could use input masks or hook up an own 'correction function' on every key press.

      Qt has to stay free or it will die.

      1 Reply Last reply
      2
      • J Offline
        J Offline
        Joel Graff
        wrote on last edited by Joel Graff
        #3

        @aha_1980 said in Pyside QLineEdit entering data from right-to-left:

        @Joel-Graff your example does not look like valid float number.
        Do you need exponential format? I'm not sure, if QDoubleSpinbox provides that, otherwise it would be first choice for that task. For the line edit, you could use input masks or hook up an own 'correction function' on every key press.

        It is, in fact, a valid float. It's called a "station" where 1 station = 100 feet. Thus 999 feet = 9.99 stations, which is commonly annotated 9+99. It's really just a length. The example I gave is actually the input mask I'm using - sorry for the confusion. The problem is, the input mask doesn't really fill out the required placeholders correctly. That is, if I create an input mask that reads:

        '00009+99.00;_'
        

        I would expect it to show

        ____0+00.__
        

        as a default. Of course, it doesn't, and I admit, I don't really know much about input masks in Qt.

        Since I can't rely on the input mask to control the data entry, forcing it to enter data from the right (and push the characters to the left) seems the next best option. It's a fairly common data entry technique - I've seen it even in very old terminal-based systems. I was hoping I didn't have to craft my own callback to manage it.

        Thanks anyway. :)

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved