TheKedge
2nd February 2007, 16:15
I've got a QTextEdit inside a sub-class of QWidget. I just want to display some simple (rich) text. I'd like the QTextEdit to scale to it's contents and the window around it around it to scale too.
class MyThing: public QWidget
{
MyThing(QWidget* parent = 0);
//...etc
private:
QTextEdit* txtEdit;
}
//the constructor
MyThing(QWidget *parent): QWidget (parent)
{
txtEdit= new QTextEdit(this) ;
QWidget::setFixedSize(txtEdit->sizeHint());
}
I think the problem is that txtEdit->sizeHint() is not influenced by the (small) amount of text in the QTextEdit. Is there any way of telling QTextEdit to occupy the minimum space possible for the given text formatting?
thanks
K
class MyThing: public QWidget
{
MyThing(QWidget* parent = 0);
//...etc
private:
QTextEdit* txtEdit;
}
//the constructor
MyThing(QWidget *parent): QWidget (parent)
{
txtEdit= new QTextEdit(this) ;
QWidget::setFixedSize(txtEdit->sizeHint());
}
I think the problem is that txtEdit->sizeHint() is not influenced by the (small) amount of text in the QTextEdit. Is there any way of telling QTextEdit to occupy the minimum space possible for the given text formatting?
thanks
K