Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly set focus on text box #20103

Closed
wants to merge 2 commits into from
Closed

Conversation

glassez
Copy link
Member

@glassez glassez commented Dec 8, 2023

Closes #20084.

@glassez glassez added the GUI GUI-related issues/changes label Dec 8, 2023
@glassez glassez added this to the 4.6.3 milestone Dec 8, 2023
@glassez glassez requested a review from a team December 8, 2023 07:13
@thalieht
Copy link
Contributor

thalieht commented Dec 8, 2023

It works but it's not the only place that needs this:

  • Add category... is not focused in Name field anymore
  • Add subcategory...
  • Edit category... for Save path
  • Add peers... in peerlist
  • Add trackers... in trackerlist
  • Edit trackers... in transferlist
  • Add torrent links
  • Off topic (not focused with Qt 6.4.3 either): maybe if you want while you're at it, focus Path in Torrent creator

Not sure if i've found everything.

@jinliu
Copy link

jinliu commented Dec 9, 2023

It works but it's not the only place that needs this:

Could this actually be a Qt bug, and should be fixed there? Yeah the Qt document doesn't specify the default focus policy for dialogs, but I don't think Qt should change it in an x.y.1 release. So it might be an unintended change.

@glassez
Copy link
Member Author

glassez commented Dec 9, 2023

Could this actually be a Qt bug, and should be fixed there? Yeah the Qt document doesn't specify the default focus policy for dialogs, but I don't think Qt should change it in an x.y.1 release.

If it was not declared to behave in a certain way, then it is not entirely correct to call such a change a bug, especially since it could not have been changed on purpose. It's better to set focus (or maybe even tab order) explicitly.

@glassez glassez marked this pull request as draft December 12, 2023 06:26
@glassez
Copy link
Member Author

glassez commented Dec 12, 2023

@thalieht, I want to try several things, but I still have no opportunity to install v6.6.1. Can you test current try?

P.S. it should be compilable with Qt 6.6.0+.

Forget. I still got Qt 6.6.1. Unfortunately, latest approach doesn't work.
I'll explore it further.

@glassez
Copy link
Member Author

glassez commented Dec 12, 2023

Now I believe it is really Qt bug.

Could you follow QTBUG-120049 and provide more info if any?

@glassez glassez removed this from the 4.6.3 milestone Dec 12, 2023
@glassez glassez added the Qt bugs Bug resides in Qt library label Dec 12, 2023
@jinliu
Copy link

jinliu commented Dec 13, 2023

I guess you can't call setFocus() before showing the dialog:
https://doc.qt.io/qt-6/qwidget.html#setFocus-1

... if this widget or one of its parents is the active window.

This suggests using a timer to delay calling setFocus():

    QTimer::singleShot(0, this, [this]
    {
        l2->setFocus();
    });

@glassez
Copy link
Member Author

glassez commented Dec 13, 2023

I guess you can't call setFocus() before showing the dialog

I can. And it works.
But now I would prefer to avoid add such workarounds and let Qt to fix this bug.

@glassez glassez closed this Dec 13, 2023
@luzpaz
Copy link
Contributor

luzpaz commented Dec 13, 2023

Maybe we all can facilitate interest in the upstream QTBUG-120049 by voting for it ?

Screenshot_20231213_061713

@glassez glassez deleted the text-focus branch December 14, 2023 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI GUI-related issues/changes Qt bugs Bug resides in Qt library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The text box is not focused in the Rename dialog (QTBUG-120049)
4 participants