Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLCDNumber fixed width for numbers
Forum Updated to NodeBB v4.3 + New Features

QLCDNumber fixed width for numbers

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 6.3k Views 1 Watching
  • 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 Offline
    B Offline
    BrainB0ne
    wrote on 18 Mar 2011, 16:42 last edited by
    #1

    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
    0
    • G Offline
      G Offline
      goetz
      wrote on 18 Mar 2011, 16:58 last edited by
      #2

      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
      1
      • B Offline
        B Offline
        BrainB0ne
        wrote on 18 Mar 2011, 17:35 last edited by
        #3

        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
        1

        1/3

        18 Mar 2011, 16:42

        • Login

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