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. QTimeedit Set Default text
Forum Updated to NodeBB v4.3 + New Features

QTimeedit Set Default text

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.5k 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.
  • S Offline
    S Offline
    SurendarK
    wrote on last edited by
    #1

    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?

    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • S SurendarK

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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
      1
      • S SurendarK

        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?

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

        @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


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

        1 Reply Last reply
        0
        • jsulmJ jsulm

          @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
          S Offline
          S Offline
          SurendarK
          wrote on last edited by
          #4

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

          mrjjM 1 Reply Last reply
          0
          • S SurendarK

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

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

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

            • Login

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