How can I make QDateTimeEdit not focusable but enabled
-
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
-
Set the QDateEdit widget on readOnly ;-)
It's a property of the QAbstractSpinBox that is inherited -
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
-
-
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
-
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