Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    QLCDNumber fixed width for numbers

    General and Desktop
    2
    3
    5940
    Loading More Posts
    • 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.
    • B
      BrainB0ne last edited by

      Is there a possible solution to the following problem?

      I am using a QLCDNumber widget in Qt 3.3.4.
      I've set the widget to use 5 digits with setNumDigits(5).

      But the LCD doesn't print the numbers the way I would like to see them display.
      The idea is that the number 0.500 will be printed like 0.500, but the LCD prints: 0.5
      and, e.g. 1.460 is printed like 1.46 which should be printed as 1.460.

      I found the same problem in the old Qt interest archive, but didn't include an answer:
      http://lists.trolltech.com/qt-interest/2005-09/thread00018-0.html

      Are there are some ideas to solve this in a simple way? :)

      1 Reply Last reply Reply Quote 0
      • G
        goetz last edited by

        I would format the number with "QString::arg() ":http://doc.qt.nokia.com/3.3/qstring.html#arg-a to a QString and set the display with "QLCDNumber::display() ":http://doc.qt.nokia.com/3.3/qlcdnumber.html#display that takes a QString as argument.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply Reply Quote 1
        • B
          BrainB0ne last edited by

          Thanks for the tip!

          It works OK, I have used QString::sprintf() for formatting, and then transfered the QString to the QLCDNumber :)

          1 Reply Last reply Reply Quote 1
          • First post
            Last post