I successfully managed to compile Qt 4 including WebKit for WinCE. QWebView seems to run fine - I can load a HTML5 document and it gets displayed.
ui.webView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
ui.webView->setUrl(QUrl::fromLocalFile(QFileInfo(QLatin1String("test.html")).absoluteFilePath()));
However, as soon as the page contains any JavaScript (even an empty script-tag already causes the problem), QWebView will only display a blank page.
The QWebInspector window can also not be shown, as it also just displays a blank window.
I doubt this is a common problem, so my question is, how I could dig into that issue. Is there any debug log for QWebView?
Unfortunately, there's no exception or assertion failure being thrown while execution.
Any ideas? :)
Thank you in advance.
EDIT:
Here is the test code creating the problem. The first four lines of loadFinished are some test code to check valid pointers and whether I could call methods on QWebFrame at all. All code lines execute well until the evaluateJavaScript, where I get an access violation.
I could not post the HTML code inside setHtml, seems to be forbidden by Stackoverflow.
ce0::ce0(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
connect(ui.webView, SIGNAL(loadFinished(bool)), SLOT(loadFinished(bool)));
ui.webView->page()->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
ui.webView->page()->settings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true);
ui.webView->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
ui.webView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
//ui.webView->setUrl(QUrl::fromLocalFile(QFileInfo(QLatin1String("test.html")).absoluteFilePath()));
ui.webView->setHtml(...);
}
void ce0::loadFinished(bool ok) {
QWebPage* p = ui.webView->page();
QWebFrame* f = p->mainFrame();
QString qs = f->title();
bool x = ui.webView->page()->settings()->testAttribute( QWebSettings::JavascriptEnabled );
f->evaluateJavaScript("document.getElementById(\"content\").innerHTML = \"Whatever\";");
}
Related
I already took at others questions but I didn't find an answer.
I have a problem to print HTML code I download with a QNetworkAccessManager.
I need to log into a website to retrieve this code.
I have a slot like this:
void Aims::slotRequestFinished(QNetworkReply* requestReply)
{
QString data = QString(requestReply->readAll());
qDebug() << data;
}
For the first two steps (connection), I can see the HTML code in the console.
The last step doesn't get any data. There is no redirection nor error.
Now, the stranger part is that when I change my code to show the page into a webview, qDebug doesn't show anything, but the code loaded is shown correctly in the webview.
void Aims::slotRequestFinished(QNetworkReply* requestReply)
{
QString data = QString(requestReply->readAll());
qDebug() << data;
ui->webView->setHtml(data);
}
Well, I can save the content into a file. But I would really like to understand why I can't see anything in qDebug
I am using the following code in order to generate QPixmap* pointers and then insert them into QHash<QString, QPixmap*> (I will show only the pointers generation code since this is the one that fails).
QPixmap* MyClass::loadImg(QString fileName)
{
QImage qimage(fileName);
if (qimage.isNull()) {
qDebug() << "Cannot load image " << fileName;
}
QPixmap *image = new QPixmap(fileName);
return image;
}
The problem that I have is the following:
For the first about 200 calls the method works fine - it is being called on a loop that iterates through the image files of a directory. Then suddenly the QPixmap* starts returning QPixmap(null) for no apparent reason.QImage is also null when that happens.
I have checked and made sure that the path is fine. Also, I have tried with various sets of images and the same always happens - it runs with no problems the ~200 calls and then starts generating nulls.
Any help would be appreciated.
Thank you.
Just don't create it on heap. QPixmap is implicitly shared.
I'm getting the following error when trying to use the Direct Show 9 backend with qt's phonon framework:
Pins cannot connect due to not supporting the same transport. (0x80040266)
Does anyone know what this error means and/or how to fix it? Is this a problem with the Direct Show 9 backend for phonon?
Apparently the problem has to do with bad metadata. If the Id3 tags aren't just right, the direct show 9 backend chokes on them. I solved the problem by writing the following function:
void removeTags(UDJ::DataStore::song_info_t& song){
static int fileCount =0;
if(song.source.fileName().endsWith(".mp3")){
UDJ::Logger::instance()->log("On windows and got mp3, copying and striping metadata tags");
QString tempCopy = QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/striped" + QString::number(fileCount) +".mp3";
if(QFile::exists(tempCopy)){
UDJ::Logger::instance()->log("Prevoius file existed, deleting now");
if(QFile::remove(tempCopy)){
UDJ::Logger::instance()->log("File removal worked");
}
}
bool fileCopyWorked = QFile::copy(song.source.fileName(), tempCopy);
if(!fileCopyWorked){
UDJ::Logger::instance()->log("File copy didn't work");
return;
}
TagLib::MPEG::File file(tempCopy.toStdString().c_str());
file.strip();
file.save();
Phonon::MediaSource newSource(tempCopy);
song.source = newSource;
if(fileCount == 3){
fileCount =0;
}
else{
fileCount++;
}
}
}
song_info_t is just a struct with a Phonon::MediaSource member in it called source. The function works by using taglib to strip off all of the metadata for a song and save the new song as a temporary file. The function also rotates the filename is uses for the temporary file so that it doesn't create an infinite number of temporary copy files. I hope this helps anyone else who is having this error.
I'm having a bit of trouble with my function for displaying pdf's with the poppler library. The code below is the function in which the problem occurs.
const QString &file is the path to the file
int page is the page on which it has to open
When i set file to a real path (e.g. "/Users/User/Documents/xxx.pdf"), it is no problem to open it. But when i give the path to a qrc file (":/files/xxx.pdf"), it won't work. I want to use it for displaying a user manual for instance, within the application.
I've also tried first making a QFile out of it, opening it and doing readAll, then loading the QByteArray received by doingPoppler::Document::loadFromData(the qbytearray), but it errors already when opening the QFile in ReadOnly mode.
void class::setPdf(const QString &file, int page)
{
Poppler::Document *doc = Poppler::Document::load(file);
if (!doc) {
QMessageBox msgbox(QMessageBox::Critical, tr("Open Error"), tr("Please check preferences: cannot open:\n") + file,
QMessageBox::Ok, this);
msgbox.exec();
}
else{ /*Code for displaying the pdf, which works fine*/
}
}
I hope you can help me,
greetings,
Matt
I've also tried first making a QFile
out of it, opening it and doing
readAll, then loading the QByteArray
received by
doingPoppler::Document::loadFromData(the
qbytearray), but it errors already
when opening the QFile in ReadOnly
mode.
QFile f;
f.setFileName(":/skin/AppIcon16.png");
f.open(QIODevice::ReadOnly);
QByteArray r=f.readAll();
Perfectly reads all data from the resource, have checked it. So i suggest you did something wrong when tried that. Maybe path errors, maybe something else...
Whenever I debug my AIR app it keeps suspending at a certain line of code...it doesn't give me a reason why, it just says Main Thread (Suspended) No error, no breakpoint at this location either. If I comment out the code so that, that line does not execute, it just does the same thing on a different line of code.
I have no clue why.... What should I do?
Thanks!!
Here is the function it happens in:
public function update (): void
{
dispatchEvent ( new Event ( EVENT_UPDATE_DOWNLOAD_STARTED ) );
var request: URLRequest = new URLRequest ( _newVersionUrl );
urlStream = new URLStream();
updateFileData = new ByteArray();
urlStream.addEventListener ( Event.COMPLETE, streamDownloadComplete );
urlStream.addEventListener ( ProgressEvent.PROGRESS, streamDownloadProgress );
urlStream.addEventListener ( IOErrorEvent.IO_ERROR, versionCheckIOErrorHandler );
urlStream.load(request);
}
this is the line it suspends on:
updateFileData = new ByteArray();
updateFileData is defined outside the function like so:
protected var updateFileData: ByteArray;
I should mention...this code is the code that Updates the version of air..could this be suspending because its trying to update while in adl.exe?
Thanks
Are you using FlexBuilder?
If you are, have you made sure there isn't a breakpoint set somewhere in your SDK source (I sometimes do this by mistake)?
Try checking, via the Debugging profile (Window > Perspective > Flex Debugging), the the Breakpoints view to see whether there's anything in there you don't recognize.
Also, when you're hung up, try stepping through the code (e.g., using F5 or F6) to see if that helps you figure out where the debugger's stopped.
Not 100% sure, because you're not hitting the error but - This might be an issue caused because the docs say you can't do the update while in the debugger:
When testing an application using the
AIR Debug Launcher (ADL) application,
attempting to update the application
results in an IllegalOperationError
exception.
This is from the livedocs.