PDA

View Full Version : QTextBrowser help please!



munna
24th April 2006, 18:33
Hi

Please have a look at the following 2 pieces of code.



ExplainBrowser b;//QTextBrowser
b.setText(str);
//b.show();
int eHeight = b.contentsHeight();//wrong height
int eWidth = b.contentsWidth();//wrong width




ExplainBrowser b;//QTextBrowser
b.setText(str);
b.show();
int eHeight = b.contentsHeight();//correct height
int eWidth = b.contentsWidth();//correct width


Is there a way by which I can the correct contentsHeight() and contentsWidth() without actually showing the widget?

Thanks a lot.

By the way I am using Qt 3.3.6

wysota
24th April 2006, 20:27
By the way I am using Qt 3.3.6

If so, then no :) At least not directly.

You could try calculating the height yourself for example using QSimpleRichText. But you have to know the width, font and other things associated with the widget. And you have to be prepared that the calculation may not be precise.