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 can I make QDateTimeEdit not focusable but enabled
Forum Updated to NodeBB v4.3 + New Features

How can I make QDateTimeEdit not focusable but enabled

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.1k Views 2 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.
  • R Offline
    R Offline
    roseicollis
    wrote on last edited by
    #1

    Hi,
    I'm making a gui app on Qt 4.8.5 with a wizard structure interactive only with keyboard. In one screen, I have:

    • a LineEdit (firstLE),
    • a qdatetimeedit (my_qdt)
    • and another lineEdit (secondLE).

    FirstLE has a text on it just to show to the user while my_qdt has the actual date and time. So the thing is that the user must put something on secondLE. For that I use secondLE->setFocus() on myWizardPAge::InitializePage() but the focus is always on firstLE and also, if I press TAB I can go to the qDateTimeEdit elements.

    What I want is that the user can only be on secondLE. I've tried with my_qdt->setEnable(false) but then the user see it in grey and I don't want that, I want it with its colors.

    Thank you so much

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Set the QDateEdit widget on readOnly ;-)
      It's a property of the QAbstractSpinBox that is inherited

      Greetz, Jeroen

      1 Reply Last reply
      0
      • R Offline
        R Offline
        roseicollis
        wrote on last edited by roseicollis
        #3

        Sorry forgot to mention it. I also tried it of course but I still can access to each member with tab (to the day, month, hour.. etc).

        The thing is that in the initialize page I set:

            secondLE->setFocus();
            firstLE->setReadOnly(true);
            my_qdt>setReadOnly(true);
        

        But when the page starts the focus is on firstLE and I can access all elements of qdt. I can't edit them but if I press Tab I go through them and what I want is that the user stays on secondLE and with tab goes only to the wizard buttons and back again to secondLE whithout passing through firstLE or my_qdt

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          IIRC, you should be able to achieve that using setTabOrder

          Hope it helps

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • R Offline
            R Offline
            roseicollis
            wrote on last edited by
            #5

            Hi SGaist,

            If I use it this way for example:

            setTabOrder(secondLE, wizard()->button(QWizard::NextButton));
            setTabOrder(wizard()->button(QWizard::NextButton), wizard()->button(QWizard::BackButton));
            setTabOrder(wizard()->button(QWizard::NextButton), secondLE);
            

            The focus starts still on firstLE and I can still access with tab to firstLE and to every element of my_qdt

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You can also set the focus on secondLE after you constructed it. If needed, add an eventFilter on firstLE where you ignore the focus events

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

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