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. how to change the line edit value into time format?
QtWS25 Last Chance

how to change the line edit value into time format?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 462 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.
  • R Offline
    R Offline
    Redho B N
    wrote on last edited by Redho B N
    #1

    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```

    JonBJ 1 Reply Last reply
    0
    • R 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```

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

      @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
      2

      • Login

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