[Qt-interest] [Fwd: [Fwd: Problem with focusNextChild and QPlainTextEdit]]

Ian Thomson Ian.Thomson at iongeo.com
Fri Mar 27 12:03:14 CET 2009


Hi,

If focusNextWidget is returning false, it means that it can't find 
another widget to give focus to. That is either because there is only 
one widget so tabbing won't take you anywhere or because there is some 
other problem. I am guessing in your case there are indeed more widgets 
so it seems like this might be a Qt bug or unusual behaviour. It is 
understandable as usually you can't shift focus out of a QPlainTextEdit 
with tab because that inserts a tab in to the text.

It could be that QPlainTextEdit is inherited from QAbstractScrollArea, 
so the actual text editor widget has unusual parentage. It might work if 
you try calling focusNextChild() on its parentWidget() or something like 
that.

Cheers,
Ian.



Stefano Rosellini wrote:
> Hi. First of all, thanks for your help.
> 
> focusNextChild returns false.
> I tried to:
>  - avoid call to QPlainTextEdit::keyPressEvent making a return.
>  - call QPlainTextEdit::keyPressEvent before focusNextChild.
>  - call QPlainTextEdit::keyPressEvent after focusNextChild.
> In all of this cases the behavior is the same: the focus remains on 
> QPlainTextEdit. The same happens on QTextEdit.
> 
> I thinked to find next focus widget myself, but I'm not sure what is the 
> correct way.
> 
> Stefano Rosellini
> Informatica Valdinievole
> 
> 
> Ian Thomson ha scritto:
>> Hi,
>>
>> Does focusNextChild return true or false? It should return true if it 
>> succeeds.
>>
>> Also, could it be that calling the QPlainTextEdit::keyPressEvent after 
>> checking for F8 means that it takes the focus back? What happens if you 
>> check for F8 after running QPlainTextEdit::keyPressEvent?
>>
>> Cheers,
>> Ian.
>>



More information about the Qt-interest-old mailing list