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

Qt-interest Archive, March 2002
Size of a QLabel with rich text


Message 1 in thread

Hi!

I want to display a little formula with a QLabel.
The formulas have the format x^a*y^b*z^c. To display the exponents I use a 
rich text with the <sup> tags.

Now the problem: The label seems to have two paragraphs or a additional 
spacing at the bottom. I attached a small pic that shows the label size.

I create the label with:
QLabel* l = new QLabel( "<qt>* x<sup>2</sup></qt>", this );
(and to show the size)
l->setFrameStyle( QFrame::WinPanel | QFrame::Sunken );

How can I remove the extra line?

Qt-version 3.0.2

-- 
 [ signature omitted ] 

Attachment: labelsize.png
Description: PNG image


Message 2 in thread


You should play with setFixedHeight() and setAlignment()
The code below produces the screenshot I have attached.

Is this close to what you want??

Enjoy,
Erlend
 
#include <qapplication.h>
#include <qlabel.h>

int main( int argc, char **argv )
{
    QApplication a( argc, argv );

	QLabel* l = new QLabel( "", 0 );
    a.setMainWidget( l );

	l->setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
	l->setAlignment(Qt::AlignHCenter);
	l->setAlignment(Qt::AlignLeft);
	l->setFixedHeight(20);
	l->setText("<qt>x<sup>2</sup></qt>");

    l->show();
    return a.exec();
}

> -----Original Message-----
> From: owner-qt-interest@trolltech.com
> [mailto:owner-qt-interest@trolltech.com]On Behalf Of Andreas Zehender
> Sent: Wednesday, March 06, 2002 14:37
> To: qt-interest@trolltech.com
> Subject: Size of a QLabel with rich text
> 
> 
> Hi!
> 
> I want to display a little formula with a QLabel.
> The formulas have the format x^a*y^b*z^c. To display the 
> exponents I use a 
> rich text with the <sup> tags.
> 
> Now the problem: The label seems to have two paragraphs or a additional 
> spacing at the bottom. I attached a small pic that shows the label size.
> 
> I create the label with:
> QLabel* l = new QLabel( "<qt>* x<sup>2</sup></qt>", this );
> (and to show the size)
> l->setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
> 
> How can I remove the extra line?
> 
> Qt-version 3.0.2
> 
> -- 
> --------------------------------------------------
>  Andreas Zehender, Dipl. Ing. (BA)
>  Student, 9. Semester Informatik
>  http://www.azweb.de
>  az@azweb.de | zehender@kde.org      
> --------------------------------------------------
> 
> 

Attachment: qlabel.bmp
Description: Windows bitmap


Message 3 in thread

Hi!

On Wednesday 06 March 2002 15:51, you wrote:
> You should play with setFixedHeight() and setAlignment()
> The code below produces the screenshot I have attached.
>
> Is this close to what you want??

Yes, that works.
Thanks.

-- 
 [ signature omitted ]