Results 1 to 5 of 5

Thread: How can i get the contents size of QTextBrowser

  1. #1
    Join Date
    Sep 2006
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default How can i get the contents size of QTextBrowser

    Is there any way to get size of the contents of QTextBrowser in Qt4?
    It seems that documentLayout()->documentSize() should do this, but this function returns a negative size after I had set the html to the corresponding QTextDocument:

    Qt Code:
    1. QTextDocument* textDoc = m_MessageBrowser->document();
    2. textDoc->clear();
    3. textDoc->setHtml( m_html );
    4. qWarning( "testDoc height = %d \n", int( textDoc->documentLayout()->documentSize().height() ) ); // prints -1
    To copy to clipboard, switch view to plain text mode 

  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: How can i get the contents size of QTextBrowser

    Maybe you should call QTextDocument::adjustSize() first or let the widget update itself first? The document size is calculated when the layout takes place, so if you ask for it just after setting the document, it is not yet calculated.

  3. #3
    Join Date
    Sep 2006
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can i get the contents size of QTextBrowser

    There is no such method in Qt4.1.4 =(
    I've tried to call adjustSize() for QTextBrowser, but it had no effect.
    I've also tried with maximumViewportSize(), but the result was too large for my single row html table

  4. #4
    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: How can i get the contents size of QTextBrowser

    Quote Originally Posted by m_e View Post
    There is no such method in Qt4.1.4 =(
    No, it was introduced in 4.2.

    I've tried to call adjustSize() for QTextBrowser, but it had no effect.
    You want the size of the document, not the widget.
    I've also tried with maximumViewportSize(), but the result was too large for my single row html table
    That concerns the widget as well, not the document.

    As I said, try calling repaint() or update() before you fetch the document layout size.

  5. #5
    Join Date
    Sep 2006
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can i get the contents size of QTextBrowser

    Quote Originally Posted by wysota View Post
    As I said, try calling repaint() or update() before you fetch the document layout size.
    Unfortunately it doesn't work too =( Anyway thanks for help.
    It seems I have to install Qt4.2...

Similar Threads

  1. Replies: 4
    Last Post: 10th December 2006, 10:04
  2. Replies: 1
    Last Post: 24th October 2006, 17:40
  3. [QT4] QtextBrowser and image size (win)
    By sebgui in forum Qt Programming
    Replies: 0
    Last Post: 28th March 2006, 22:01
  4. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 23:14
  5. how to adjust sizes of QTextBrowser?
    By Pan Wojtas in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2006, 23:25

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.