Qt Forum

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

    Unsolved QTimeedit Set Default text

    General and Desktop
    4
    5
    982
    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.
    • S
      SurendarK last edited by

      Greetings to all,

      I have a few queries about QTimeedit class.

      1. I want to set Default text "HH:MM" in QTimeedit field. Is it possible to do?

      2. Is it possible to clear the minutes or hours field? Or
        Is it possible to clear the particular field to be empty whenever i press the mouse button in the QTimeedit?

      jsulm J.Hilk 2 Replies Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @SurendarK last edited by

        @SurendarK

        1. Please take a look at http://doc.qt.io/qt-5/qdatetimeedit.html#displayFormat-prop
        2. What do you mean by "empty"? 00? You can set for example 00:00

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        S 1 Reply Last reply Reply Quote 1
        • J.Hilk
          J.Hilk Moderators @SurendarK last edited by

          @SurendarK

          look at that, theres a QTimeEdit class, seems like I reinveted the wheel a couple of times in the past...

          Anyway,

          you can look into InputMethodHints to set the Inputmask to HH:MM
          Doesn't seem like QTimeEdit has a Placeholdertext-option so you'll have to set the Text to your default by hand, right after the construction.

          There 're a couple of ways to intercept and Keyboard/Mousevents. I suggest lookin into Event Filters and Event Handlers.
          'Catch' the mouse press/click event, check if a QtimeEdit ist focused if it is -> clear it.

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

          Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

          1 Reply Last reply Reply Quote 0
          • S
            SurendarK @jsulm last edited by

            @jsulm
            Thanks for your comments.
            The word i meant by empty is the field is blank that is ( : ) not to set 00:00.Is it possible???

            mrjj 1 Reply Last reply Reply Quote 0
            • mrjj
              mrjj Lifetime Qt Champion @SurendarK last edited by

              @SurendarK
              Hi, no, its not possible to have empty date like that.
              The docs says
              "If you specify an invalid format the format will not be set."
              So it must be valid. :)

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