PDA

View Full Version : QWebView problem with flash



TuBylem
25th September 2010, 14:10
Hi guys,
I had written a music player application in C# and I have decided to rewrite it in QT, but I have a huge problem with QWebView (which is similar to WebBrowser in C#). My application uses a flash player from the website. WebBrowser's (C#) WebBrowserProgressChangedEvent sends to me the signal (-1), when the flash player has just finished his job, but QWebView doesn't. In this application I have to know when a current track is finished, to start the next one, so please help me. How can I solve this problem?

I have attached console diagrams from both applications (they say how WebBrowserProgressChangedEvent (C#) and loadProgress(int) (QT) signals are changing) and QT source code
C# application
5237
QT application
5238

source code
MainWindow.h


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QListWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
#include <QtWebKit/QWebView>

class MainWindow : public QWidget
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private:
QVBoxLayout *verticalLayout;
QWebView *webView;
QListWidget *listWidget;

void setupUi(QWidget *MainWindow);

private slots:
void progressChanged(int progress);
};

#endif // MAINWINDOW_H

MainWindow.cpp


#include "MainWindow.h"

MainWindow::MainWindow(QWidget *parent) : QWidget(parent)
{
setupUi(this);
connect(webView, SIGNAL(loadProgress(int)), this, SLOT(progressChanged(int)));
}

MainWindow::~MainWindow()
{
}

void MainWindow::progressChanged(int progress)
{
listWidget->addItem(QString::number(progress));
}

void MainWindow::setupUi(QWidget *widget)
{
webView = new QWebView(widget);
webView->setFixedSize(250, 70);
webView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
webView->setUrl(QUrl("http://w618.wrzuta.pl/audio.swf?key=aL9BKZ2y9Lb&host=wrzuta.pl&autoplay=y"));

listWidget = new QListWidget(widget);

verticalLayout = new QVBoxLayout(widget);
verticalLayout->addWidget(webView);
verticalLayout->addWidget(listWidget);

widget->setLayout(verticalLayout);
}

test2.pro


QT += webkit

TARGET = test2
TEMPLATE = app


SOURCES += main.cpp\
MainWindow.cpp

HEADERS += MainWindow.h