Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, April 2008
A query regarding the way QComboBox displays its contents in reverse layout languages


Message 1 in thread

________________________________

Hello folks,

This is Subramanian. Actually using QComboBox in our application in
Hebrew correctly mirrors the Combo but the contents of the combo are
still aligned to the left edge of the combo ( since the combo is now
mirrored "left edge" is the edge with the arrow control that pops up the
list box, is it as Designed? because another app(written using another
toolkit) with which our app communicates, displays the combo contents
aligned to the right edge in reverse layout languages. 

I guess the contents are displayed in the correct way though(just
guessing cos i dont understand hebrew  and figured it out by comparing
the individual glyphs in the combo with other glyphs appearing all over
the apps, found consistent looking from right to left),

Is there any way to exercise finer control over the display? In the
words of Qt doc,

QPainter::drawText( int x, int y, const QString &str ) will always draw
the string with it's left edge at the position specified with the x, y
parameters. This will usually give you left aligned strings. Arabic and
Hebrew application strings are usually right aligned, so for these
languages use the version of drawText() that takes a QRect since this
will align in accordance with the language. 

if that is the case why then do line edit contents and label text are
painted in the expected way and why not the combo?

Please dont mind if the question seems silly, just about beginning to do
serious stuff with Qt, infact created my first real dialog last week and
i did my homework regarding the same...if it is as designed do we need
to customize the combo and reimplement paintEvent?if it is not tell me
what should i pass to the created combo.

 

With Best Regards,

Subramanian 

 

GIF image

GIF image


Message 2 in thread

On Wednesday 02 April 2008 08:58:03 Subramanian Ganapathy wrote:
> ________________________________
>
> Hello folks,
>
> This is Subramanian. Actually using QComboBox in our application in
> Hebrew correctly mirrors the Combo but the contents of the combo are
> still aligned to the left edge of the combo ( since the combo is now
> mirrored "left edge" is the edge with the arrow control that pops up the
> list box, is it as Designed? because another app(written using another
> toolkit) with which our app communicates, displays the combo contents
> aligned to the right edge in reverse layout languages.
>
> I guess the contents are displayed in the correct way though(just
> guessing cos i dont understand hebrew  and figured it out by comparing
> the individual glyphs in the combo with other glyphs appearing all over
> the apps, found consistent looking from right to left),
>
> Is there any way to exercise finer control over the display? In the
> words of Qt doc,
>
> QPainter::drawText( int x, int y, const QString &str ) will always draw
> the string with it's left edge at the position specified with the x, y
> parameters. This will usually give you left aligned strings. Arabic and
> Hebrew application strings are usually right aligned, so for these
> languages use the version of drawText() that takes a QRect since this
> will align in accordance with the language.
>
> if that is the case why then do line edit contents and label text are
> painted in the expected way and why not the combo?
>
> Please dont mind if the question seems silly, just about beginning to do
> serious stuff with Qt, infact created my first real dialog last week and
> i did my homework regarding the same...if it is as designed do we need
> to customize the combo and reimplement paintEvent?if it is not tell me
> what should i pass to the created combo.

The alignment of the contents is part of the layout, which is controlled by 
the layout direction. If you use Qt::RightToLeft as layout direction on the 
widget (combobox) or on the application (QApplication::setLayoutDirection, 
http://doc.trolltech.com/4.3/qapplication.html#layoutDirection-prop ) you 
will see that the contents will be aligned to the right.


Simon

Attachment:

Attachment: signature.asc
Description: This is a digitally signed message part.


Message 3 in thread

Thanks a lot Simon.

Subramanian

-----Original Message-----
From: Simon Hausmann [mailto:simon.hausmann@xxxxxxxxxxxxx] 
Sent: Thursday, April 03, 2008 12:39 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: A query regarding the way QComboBox displays its contents
in reverse layout languages

On Wednesday 02 April 2008 08:58:03 Subramanian Ganapathy wrote:
> ________________________________
>
> Hello folks,
>
> This is Subramanian. Actually using QComboBox in our application in
> Hebrew correctly mirrors the Combo but the contents of the combo are
> still aligned to the left edge of the combo ( since the combo is now
> mirrored "left edge" is the edge with the arrow control that pops up
the
> list box, is it as Designed? because another app(written using another
> toolkit) with which our app communicates, displays the combo contents
> aligned to the right edge in reverse layout languages.
>
> I guess the contents are displayed in the correct way though(just
> guessing cos i dont understand hebrew  and figured it out by comparing
> the individual glyphs in the combo with other glyphs appearing all
over
> the apps, found consistent looking from right to left),
>
> Is there any way to exercise finer control over the display? In the
> words of Qt doc,
>
> QPainter::drawText( int x, int y, const QString &str ) will always
draw
> the string with it's left edge at the position specified with the x, y
> parameters. This will usually give you left aligned strings. Arabic
and
> Hebrew application strings are usually right aligned, so for these
> languages use the version of drawText() that takes a QRect since this
> will align in accordance with the language.
>
> if that is the case why then do line edit contents and label text are
> painted in the expected way and why not the combo?
>
> Please dont mind if the question seems silly, just about beginning to
do
> serious stuff with Qt, infact created my first real dialog last week
and
> i did my homework regarding the same...if it is as designed do we need
> to customize the combo and reimplement paintEvent?if it is not tell me
> what should i pass to the created combo.

The alignment of the contents is part of the layout, which is controlled
by 
the layout direction. If you use Qt::RightToLeft as layout direction on
the 
widget (combobox) or on the application
(QApplication::setLayoutDirection, 
http://doc.trolltech.com/4.3/qapplication.html#layoutDirection-prop )
you 
will see that the contents will be aligned to the right.


Simon

--
 [ signature omitted ]