But it makes "segmentation fault"...Originally Posted by piotrpsz
But it makes "segmentation fault"...Originally Posted by piotrpsz
QLabel is not a container, thus it doesn't have a layout (unless you provide one, but I don't know what will happen then... QLabel is not supposed to have a layout).
i did some testing on QT4. I know you're on QT3, but i wanted to see the behaviour here also.What can I do to avoid this red border above, below
QT4 doesn't provide the left and right margins, but you get top and bottom margins. So this is better than QT3.
But the margins on top and bottom arestill there.
I noticed I could drag the dialogbox to a minimum size = sizehint of the textlabel. I couldn't drag it smaller. (because of QT's wonderfull sizehint functionality)
So here is my dirty trick :
label->resize(1,1);//resize it to 1 by 1 pixel, which QT won't allow.
and in QT4 the dialogbox is the size you want without the margins.
I hope it will work for QT3 also.
Cheers
It resize this QLabel ALWAYS to minimal size, so the table is without margins, but Qt doesn't show the whole table...Originally Posted by Everall
gives:Qt Code:
label->resize(1,1); label->setBackgroundMode(Qt::FixedColor); label->setText("<table width=\"100%\" bgcolor=white border=0 cellspacing=0 cellpadding=0><tr><td>aaa<br>ccc<br>ddd</td><td>bbb</td></tr></table>"); label->show();To copy to clipboard, switch view to plain text mode
How does it look on Qt4?
I've seen in some sources this trick with resize(1,1), but I don't remember exacly where it was... I'll look for it.
Last edited by Pan Wojtas; 6th February 2006 at 15:34.
it looks like :How does it look on Qt4?
Cheers
QLabel is a QWidget.Originally Posted by wysota
Every QWidget have a layout (QWidget have a function member QLayout* layout()).
Maybe is not used, but have layout.
Piotr
Eeem.... no.Originally Posted by piotrpsz
Qt Code:
#include <qwidget.h> #include <qlayout.h> #include <qapplication.h> int main(int argc, char **argv){ w->layout()->setMargin(5); delete w; return 0; }To copy to clipboard, switch view to plain text mode
On my system it crashes on "w->layout()->setMargin()" call, meaning there is no layout in the widget. A class may have methods to get or set a layout, but it doesn't mean it uses them. If you take a look at QWidget sources, you'll notice, that it only references "layout" while dealing with "height for width".
OKOriginally Posted by wysota
Sorry, I should tell, that every widget CAN have a layout.
Look a previous my post.
Best regards
Piotr
So set a layout for QWidget and try to do anything meaningfull with it...
I've noticed, that this extra margin on the bottom is always equal
to "fontMetrics().height()", so it seems that Qt adds one empty line below
each table...
That's right.Originally Posted by Pan Wojtas
For label function layout() returns 0 (NULL).
But try this code:
Qt Code:
if( 0 == lay ) qWarning( "lay is 0" ); else qWarning( "OK" ); lbl->layout()->setMargin( 0 ); lbl->layout()->setSpacing( 0 );To copy to clipboard, switch view to plain text mode
This code functioning.
Piotr
Bookmarks