[mythtv] MythPopupBox losing focus

Tako Schotanus quintesse at palacio-cristal.com
Sat Oct 11 14:32:53 EDT 2003


How about QWidget::isFocusEnabled() ?

Philippe C.Cattin wrote:

> Isaac,
>
>> The best thing to do would be to have MythPopupBox (or MythDialog, 
>> really) make its own focusNextPrevChild() method to override the 
>> default QWidget one.  That way, it can restrict focus to the popup 
>> box's own children, and not pass the decision of what to move focus 
>> to up the widget tree.  I'll look into doing this if no one else 
>> manages to get to it by the weekend.
>>
>> Isaac
>
>
>   okay, I have a solution that does the job for MythPopupBox. It 
> dynamically generates a QPtrList with the QButton widgets we possible 
> want to cycle through (thus ignoring QLabels and stuff).
>
>   However, in case of MythDialog there are more widgets that can have 
> user interaction. But what widgets should I check for??? Or should I 
> cycle through all the widgets exept QLabel,...???
>
>   Is there a better solution than the dynamic_cast hack to find out 
> what kind of widget I'm dealing with?
>
> any suggestions?
>
> regards, Philippe
>
>
> ### ### ###
>
> bool MythPopupBox::focusNextPrevChild(bool next)
> {
>     if (!widgetList)
>     {
>         selected=0;
>
>         // Recursively generate list of all children
>         QObjectList *l = queryList(NULL,NULL,false,true);
>         QObjectListIt it(*l); // iterate over all the children
>
>         // Generate list of all widgets we want to cycle through
>         widgetList = new QPtrList<QWidget>();
>         while ((objs = it.current()) != 0)
>         {
>             if (dynamic_cast<QButton*>(objs))
>             {
>                 QWidget *widget = (QWidget *)objs;
>                 if(widget->hasFocus())
>                     selected=widgetList->count();
>                 widgetList->append(widget);
>             }
>             ++it;
>         }
>         delete l; // delete the list, not the objects
>     }
>
>     if(next)
>     {
>         selected++;
>         if(selected>=(int)widgetList->count())
>             selected=0;
>     }
>     else
>     {
>         selected--;
>         if(selected<0)
>             selected=widgetList->count()-1;
>     }
>     widgetList->at(selected)->setFocus();
>     return true;
> }
>
>------------------------------------------------------------------------
>
>_______________________________________________
>mythtv-dev mailing list
>mythtv-dev at mythtv.org
>http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mythtv.org/pipermail/mythtv-dev/attachments/20031011/fcceb33e/attachment.html


More information about the mythtv-dev mailing list