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. QDoubleSpinBox with Hexadecimal value
Forum Updated to NodeBB v4.3 + New Features

QDoubleSpinBox with Hexadecimal value

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 453 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.
  • sitesvS Offline
    sitesvS Offline
    sitesv
    wrote on last edited by
    #1

    Hi!
    Trying to use QDoubleSpinBox to show uint64 values in hex.
    QDoubleSpinBox is good for uint64 values, but is not good for hex view.
    Is it possible?
    Thank you!

    J.HilkJ JonBJ 2 Replies Last reply
    0
    • sitesvS sitesv

      Hi!
      Trying to use QDoubleSpinBox to show uint64 values in hex.
      QDoubleSpinBox is good for uint64 values, but is not good for hex view.
      Is it possible?
      Thank you!

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @sitesv sure, override textFromValue


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      2
      • sitesvS sitesv

        Hi!
        Trying to use QDoubleSpinBox to show uint64 values in hex.
        QDoubleSpinBox is good for uint64 values, but is not good for hex view.
        Is it possible?
        Thank you!

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @sitesv
        QDoubleSpinBox deals in doubles rather then the int of QSpinBox, and it does not have the "integer base" option of the latter. Floating point values do not offer the ability to use a non-10 base supported in integers.

        You may have to roll your own. I think you would be better heading out from a QSpinBox-type with an int64 value than QDoubleSpinBox's double. See e.g. How to subclass QSpinBox so it could have int64 values as maxium and minimum, the solution there does not look like too much code. There is also https://stackoverflow.com/a/26581445/489865 if you need help on the hex digit side of things. Further examples are available by Googling qspinbox int64.

        P.S.
        Thinking about it, double cannot represent the full range of values for uint64 since both are 64-bits big! So if you are wanting to use the full range you will have abandon double as your type!

        1 Reply Last reply
        3

        • Login

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