PDA

View Full Version : setHtml and QtConcurrent problem



andrepimenta
31st December 2011, 06:14
MainWindow::MainWindow()
{

centralWidget = new Previewer(this);
setCentralWidget(centralWidget);
QFuture<void> future = QtConcurrent::run(this, &MainWindow::setStartupText);

}


void MainWindow::setStartupText()
{

QString string = "<html><body><h1>HTML Previewer</h1>"
" <p>This example shows you how to use QWebView to"
" preview HTML data written in a QPlainTextEdit.</p>"
"<div id='a'> </div> <input type='button' onclick=\"Qt.viewphp()\"></body></html>";
centralWidget->webView->setHtml(string);
}

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

wysota
1st January 2012, 21:06
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?