PDA

View Full Version : Need help with QWebView rendering html with flash positioning problem



JasonKretzer
1st July 2013, 21:56
Background Information
Using Qt5.0.2
MainWindow is a QMainWindow
MainWindow contains 2 QWidgets (q and q2)
q is red and has q->setGeometry(50,50, 400,400);
q2 is blue and has q2->setGeometry(75,75,200,200);
q2 contains a QWebView (mWebView)
mWebView is green and has mWebView->setGeometry(20,20,100,100);
mWebView loads an html resource file that has a flash embedded.

The mWebView is resized, the html file loads, and the flash “plays” just fine.

The problem is that it plays in the top left corner of MainWindow and will not be moved. If I change the content of the html to just html, it is positioned just fine. However, the flash will only play in the top left.

Is this a Qt bug? I could really use some help here.

Here is the code and a screenshot.
http://i41.tinypic.com/r1k194.jpg also attached to post9257



#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
//set the main window geometry
setGeometry(25,25,800,600);


QPalette p(palette());
p.setColor(QPalette::Background, Qt::red);

//put a widget out there for contrast
QWidget * q = new QWidget(this);
q->setAutoFillBackground(true);
q->setPalette(p);
q->setGeometry(50,50, 400,400);

//put another widget out there for further contrast
QWidget * q2 = new QWidget(q);
p.setColor(QPalette::Background, Qt::blue);
q2->setAutoFillBackground(true);
q2->setPalette(p);
q2->setGeometry(75,75,200,200);

//this is a QWebView defined in .h
mWebView = new QWebView(q2);
p.setColor(QPalette::Background, Qt::green);
mWebView->setAutoFillBackground(true);
mWebView->setPalette(p);

//configure the web view
mWebView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
mWebView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
mWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

//read in the resource file that contains the flash
mWebView->setUrl(QUrl("qrc:/html/flashwrapper.html"));
mWebView->page()->mainFrame()->load(QUrl("qrc:/html/flashwrapper.html"));

//***** RESIZE AND MOVE DID NOT WORK ******//
//mWebView->resize(100,100);
//mWebView->move(20,20);

//ALSO TRIED THE SETGEOMETRY
mWebView->setGeometry(20,20,100,100);

}

MainWindow::~MainWindow()
{

}