Results 1 to 2 of 2

Thread: QTextBrowser help please!

  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QTextBrowser help please!

    Hi

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

    Qt Code:
    1. ExplainBrowser b;//QTextBrowser
    2. b.setText(str);
    3. //b.show();
    4. int eHeight = b.contentsHeight();//wrong height
    5. int eWidth = b.contentsWidth();//wrong width
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. ExplainBrowser b;//QTextBrowser
    2. b.setText(str);
    3. b.show();
    4. int eHeight = b.contentsHeight();//correct height
    5. int eWidth = b.contentsWidth();//correct width
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextBrowser help please!

    Quote Originally Posted by munna
    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.

Similar Threads

  1. link from QTextBrowser to QWebView
    By lamera in forum Qt Programming
    Replies: 4
    Last Post: 12th October 2008, 15:46
  2. Replies: 1
    Last Post: 5th August 2008, 20:44
  3. QTextBrowser: Cannot open
    By veda in forum Qt Programming
    Replies: 3
    Last Post: 27th December 2007, 12:05
  4. qtextbrowser stop scrolling on append
    By tpf80 in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2007, 20:28
  5. [QT4] QtextBrowser and image size (win)
    By sebgui in forum Qt Programming
    Replies: 0
    Last Post: 28th March 2006, 21:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.