Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Focus issue in Multiple Widget in Layout.



  • Dear Friends,
    I am having QWidget(A) which holds another Qwidget(B) .Now QWidget(B) holds another ModuleMessageBox that have 3 buttons yes,No And Cancel. My aim is only that focus should be always on cyclcic between yes no and cancel. Currently I have implemented like in the parent widget event filter i check for the focus out event and there i set for ModuleMessagebox . And in the parent constructor(A) i set the setfocuspolicy(Qt::StrongFocus)

    if(o == parent(A) && e->type() == QEvent::FocusOut)
        {
            if(ModuleMessagebox)
            ModuleMessagebox->setFocus(Qt::TabFocusReason);
        }
    

    Now I am facing the problem like on the key tab if i am changing the focus .is is going on yes then No and then Cancel.After that I have to press 2 times more for getting again the focus on yes button.I want it should be cyclic.
    I have tried a lot of things but not successful.

    Any hints will be appreciated.
    TIA


  • Lifetime Qt Champion

    Hi,

    Are you using a QDialogButtonBox ?



  • @SGaist : Hi,
    yes it is QDialogButtonBox and we have Standard button as enum(Yes ,No,cancel). My one Problem is solved that cyclic one.Now I have only one problem that the when we start the ModuleMessageBox the focus should always be on Yes button.currently i am trying to do that i know its very simple thing but some how its not working.When i press the tab key then only focus comes on Yes button.
    Please advise



  • @SGaist : Thanks for your input.I fixed the issue by setFocus in ShowEvent().So i mark it as resolved.


Log in to reply