Results 1 to 2 of 2

Thread: setHtml and QtConcurrent problem

  1. #1
    Join Date
    Dec 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default setHtml and QtConcurrent problem

    Qt Code:
    1. MainWindow::MainWindow()
    2. {
    3.  
    4. centralWidget = new Previewer(this);
    5. setCentralWidget(centralWidget);
    6. QFuture<void> future = QtConcurrent::run(this, &MainWindow::setStartupText);
    7.  
    8. }
    9.  
    10.  
    11. void MainWindow::setStartupText()
    12. {
    13.  
    14. QString string = "<html><body><h1>HTML Previewer</h1>"
    15. " <p>This example shows you how to use QWebView to"
    16. " preview HTML data written in a QPlainTextEdit.</p>"
    17. "<div id='a'> </div> <input type='button' onclick=\"Qt.viewphp()\"></body></html>";
    18. centralWidget->webView->setHtml(string);
    19. }
    To copy to clipboard, switch view to plain text mode 

    When I do this the text appears in the webView but with no format at all. The <h1> doesn't work and the <input type='button'> doesn't appear,etc.
    Am I doing something wrong ? Is this not possible to do?
    (This is from previewer example by the way.)
    Please help me !

    Andre Pimenta
    Last edited by andrepimenta; 31st December 2011 at 05:21.

  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: setHtml and QtConcurrent problem

    You cannot interact with widgets from within threads. It either won't work or will crash you app. What's the point of trying to use a thread here?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Problem with QtConcurrent::run
    By januszmk in forum Newbie
    Replies: 5
    Last Post: 30th July 2011, 17:57
  2. How to use QMimeData::setHtml?
    By Vadi in forum Qt Programming
    Replies: 4
    Last Post: 25th January 2011, 16:52
  3. Problem with setHtml in QWebPage on Symbian S60
    By real_ate in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 25th January 2010, 20:12
  4. QGraphicsTextItem - setHTML()
    By Claymore in forum Qt Programming
    Replies: 7
    Last Post: 17th September 2009, 09:34
  5. editor->setHtml doesn't
    By GreyGeek in forum Qt Programming
    Replies: 4
    Last Post: 17th February 2007, 13:15

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.