Qt Forum

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

    Unsolved how to change the line edit value into time format?

    General and Desktop
    2
    2
    293
    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.
    • R
      Redho B N last edited by Redho B N

      so i want to change the the format of the lineedit value from int to time format like hhh:mm wheres when the mm is >59 it will made the hhh added by 1 but the hhh didn't end after 24. and the time format can be added by one another too like this.
      0_1553155433258_8b17078a-3db8-4b45-b466-fcacfb5007b9-image.png
      thanks```

      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @Redho B N last edited by JonB

        @Redho-B-N
        First, be aware there is a Qt widget QTimeEdit, https://doc.qt.io/qt-5/qtimeedit.html. However, that effectively displays a "time of day", whereas I think your need is for a time duration instead.

        You can see this discussed in an old post on this forum, https://forum.qt.io/topic/19617/how-to-implement-a-widget-for-durations-similar-to-qtimeedit. Unfortunately the link for example code for a QTimeSpan there does not seem to point to anything which works. But the sentiment is correct: you need to roll your own, using a QLineEdit or QSpinbox. Your code must implement the necessary addition logic to convert to hours + minutes, as necessary.

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