Dears,
I want to show flash in QTWebkit and have done the following steps
1. Code:
QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptEnabled, true);
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
2. export QT_PLUGIN_PATH= the directory contains the libflashplayer.so
But flash still can’t show normally.
Any one can help?
Thanks,
↧
Problem with playing flash with QTWebkit 4.8.5
↧
Punching a hole in QT5.0
I have a QT Application with Video running and QT Graphics is on top of it. I need to punch a hole so that all graphics layer in a rectangle become transparent and Video becomes visible.
I checked setMask, but with this API, the hole rectangle becomes white. This is the snippet –
QRegion r1(0, 0, 1280, 800, QRegion::Rectangle);
QRegion r2(0, 150, 600, 480, QRegion::Rectangle);
QRegion visibleReg = r1.subtracted (r2);
setMask(visibleReg);
Any help would be appreciated. I am using QT5.
↧
↧
Qt 4.8.4 WebKit Inspector Context Menus don't show up?
In Qt I’ve already made it so that Inspect shows up in my QtWebKit context menus and upon selection the Inspector appears as expected. So far so good.
The problem is that if I, say, goto the Network tab and right-click within the Inspector I just get a little 1px square, whereas in Chrome proper I get a context menu with ‘Clear browser cache’ and ‘Clear browser cookies’ among other options.
The little 1px square is what happens in Qt if one tries to show an empty QMenu… so this feels like a bug in QtWebKit, but wasn’t sure if maybe I’m just failing to twiddle some debug options on. Anybody have more insight?
↧
How to Enable Debugging in WebKit Inspector so It's Available On Page Load?
I can enable debugging in WebKit Inspector manually by opening it, going to the Scripts tag, choosing ‘Always enable’ and then clicking ‘Enable Debugging’. However, if I close the Qt app and open it again, that all has to be done again, the upshot being that I can’t seem to find a way to have debugging enabled for the page’s initial load.
The QWebInspector page even has a section on “Inspector configuration persistence,” but following the directions there seems to have no effect. Does anybody know how to either programatically enable debugging for the inspector or else how to get the settings to actually persist?
↧
Linker fails using qt-project built standalone with a strange error
Hello There,
I just hope someone can help me since this issue gets really miserable.
What I have done:
1. Downloaded “Qt 5.1.0 for Linux 64-bit (416 MB)” from http://qt-project.org/downloads
2. Installed to default path, including sources
3. Set PATH variable in .bash_profile so qmake is found
4. Created a tiny application what just opens a window using “webkitwidgets” and downloads a website.
5. Complied on Windows. Works fine there. Tried to compile on linux.
6. qmake was fine. Makefile is generated and looks okay.
7. Miserable errors are happening on make:
g++ -Wl,-rpath,/opt/Qt5.1.0/5.1.0/gcc_64 -Wl,-rpath,/opt/Qt5.1.0/5.1.0/gcc_64/lib -Wl,-rpath-link,/opt/Qt5.1.0/5.1.0/gcc_64/lib -o bin/JsRendererWebkit WebkitJs.o main.o moc_WebkitJs.o -L/opt/Qt5.1.0//5.1.0/gcc_64/lib -lQt5WebKitWidgets -lQt5Quick -lQt5OpenGL -lQt5PrintSupport -lQt5Declarative -lQt5WebKit -lQt5Qml -lQt5Widgets -lQt5Network -lQt5Sensors -lQt5Script -lQt5Gui -lQt5Core -lGL -lpthread
/opt/Qt5.1.0//5.1.0/gcc_64/lib/libQt5WebKit.so: undefined reference to `deflateBound@ZLIB_1.2.0'
/opt/Qt5.1.0//5.1.0/gcc_64/lib/libQt5WebKit.so: undefined reference to `g_variant_ref'
/opt/Qt5.1.0//5.1.0/gcc_64/lib/libQt5WebKit.so: undefined reference to `std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)@GLIBCXX_3.4.15'
/opt/Qt5.1.0//5.1.0/gcc_64/lib/libQt5WebKit.so: undefined reference to `gst_x_overlay_set_window_handle'
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64/libGL.so: undefined reference to `xcb_glx_set_client_info_arb'
/opt/Qt5.1.0//5.1.0/gcc_64/lib/libQt5WebKit.so: undefined reference to `gst_query_parse_nth_buffering_range'
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64/libGL.so: undefined reference to `xcb_glx_create_context_attribs_arb_checked'
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64/libGL.so: undefined reference to `xcb_glx_set_client_info_2arb'
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64/libGL.so: undefined reference to `_XGetRequest'
/opt/Qt5.1.0//5.1.0/gcc_64/lib/libQt5WebKit.so: undefined reference to `g_variant_unref'
/opt/Qt5.1.0//5.1.0/gcc_64/lib/libQt5WebKit.so: undefined reference to `gst_element_link_pads_full'
/opt/Qt5.1.0//5.1.0/gcc_64/lib/libQt5WebKit.so: undefined reference to `gst_is_initialized'
/opt/Qt5.1.0//5.1.0/gcc_64/lib/libQt5WebKit.so: undefined reference to `gst_query_get_n_buffering_ranges'
collect2: ld returned 1 exit status
make: *** [bin/JsRendererWebkit] Error 1
The O/S is CentOS 6.0 ×64. Both mesa GL, GLU, devels are installed. Libraries are found in /usr/lib64.
I looked through the net searching for ideas. The only one I found was that gstreamer version might be wrong. So I tried:
Install gstreamer as:
sudo yum install gstreamer
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
* base: ftp.freepark.org
* extras: ftp.freepark.org
* updates: ftp.freepark.org
Setting up Install Process
Package gstreamer-0.10.29-1.el6.x86_64 already installed and latest version
Nothing to do
9. I could not find any clue on what gstreamer version the WebKit supplied witn Qt 5.1.0.
10. Please help me! What should I do to get my make done?
Thanks :)
↧
↧
how to unload browser plugins automatically when leave current url page
now i load browser plugin at the beginning of start a page, but how qt webkit unload these pluginss when jump to another url page?
↧
Getting XML document from server and extracting strings from it
Good day fellow programmers,
I am trying to communicate with a rest API web service, get a xml document and then parse it’s values into strings.
Since I am new to this topic any help would be greatly appreciated!
This is what I built using the XMLHTTPREQUEST example:
import QtQuick 2.0
Rectangle {
width: 350; height: 400
function showRequestInfo(text) {
log.text = log.text + "\n" + text
console.log(text)
}
Text { id: log; anchors.fill: parent; anchors.margins: 10 }
Rectangle {
id: button
anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.margins: 10
width: buttonText.width + 10; height: buttonText.height + 10
border.width: mouseArea.pressed ? 2 : 1
radius : 5; smooth: true
Text { id: buttonText; anchors.centerIn: parent; text: "Request" }
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
log.text = ""
console.log("\n")
var doc = new XMLHttpRequest();
doc.onreadystatechange = function() {
if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
} else if (doc.readyState == XMLHttpRequest.DONE) {
var a = doc.responseXML.documentElement;
for (var ii = 0; ii < a.childNodes.length; ++ii) {
showRequestInfo(a.childNodes[ii].nodeName);
}
}
}
doc.open("POST", 'http://www.example.com/mydata.xml');
doc.send();
}
}
}
}
This code does successfully communicate with the server and retrieves information from it.
The problem is that it only names the node’s name but leaves the values out.
Example response:
is-admin
#text
signature
#text
restrictions
#text
How can I fix this and manage to save the information retrieved with the xml document into strings?
Thanks a LOT in advance!
↧
Qt5 WebKit not displaying fonts when compiled on Ubuntu Server
I have a Qt5 webkit instance running to make screenshots of webpages on a server. The Qt5 version is replacing a fully functional Qt4 server that leaked memory and had threading issues.
The Qt5 webkit instance works when compiled on Ubuntu 13.04 desktop, however on the same server where the Qt4 version worked, the Qt5 version renders no fonts at all, not even custom css fonts from the webpage being displayed.
Any ideas if this is a compile flag, a Qt setting somewhere, or ubuntu packages I need to install? I am using the same version of Ubuntu’s package-managed Qt5 on both systems.
Here is a screenshot comparing the rendering
http://cl.ly/image/2F3f3b3r1S1I
I’m getting a lot of this message:
QFontDatabase: Cannot find font directory ‘/usr/lib/x86_64-linux-gnu/fonts’ – is Qt installed correctly?
However on ubuntu it shouldn’t be looking there for fonts, but in the system-wide fonts folder.
↧
Web security origin policy on Webkit2/ QtWebkit 3.0 On QML
I am using QtWebkit 3.0 [ WK2 ] on QtQuick 2.
I could not find any API to turn the web-security-origin policy anywhere!
Any hint on this to proceed ,is very much appreciable.
↧
↧
QWebView using setHtml :- images do not refresh
I’m using setHTML to display some generated, template-based HTML which also contains some generated images. By template-based, I mean that I have a “template” HTML file which I read in as text, then I replace some portions of this text with data generated from my application, then set the result in the WebView using setHtml(). My application also includes a couple of images, which have fixed filenames, which the application generates, and which are displayed in the QWebView.
This all works fine the first time.
The problem I have is that if the application data changes, and I regenerate the HTML, and save new images (overwriting the previous ones) the QWebView (or some internal component) doesn’t display the changed images – I presume it uses cached copies of the images which use the same names.
Normally, things work ok if you Refresh (QWebPage::Reload) – that is, if you’re rendering a file or server-based page – then images are updated. However, in the this case of using setHtml(), the refresh actually reloads the HTML based on the URL given in the setHtml baseUrl parameter – in my case it opens my template HTML file (I need pass this in setHtml so that the correct paths are used to find the style sheet(s) and images).
Clearly I can fix this by using a temporary file – basically put my generated HTML in there, and just load that file normally, and all should work with a refresh. Actually this is not an issue since my files are small.
Still I feel it’s not quite right, and I suppose that this could be a problem when using these classes for manual editting for example.
So, does this issue ring any bells with anyone ? Does something similar happen when editting pages ? Is there an image cache which can be forced to refresh which I’ve missed in the docs ? Or is there some less explicit way to get the cache to update, or to switch off ? (I tried settings->setMaximumPagesInCache( 0 );)
↧
Browser example fails
Windows 7, Qt5.1.1(5.1.0)
just running the tab browser example makes it to crash
stack trace:
0 WTF::HashTable<WTF::RefPtr<WTF::StringImpl>, WTF::KeyValuePair<WTF::RefPtr<WTF::StringImpl>, WebCore::IdentifierRep*>, WTF::KeyValuePairKeyExtractor<WTF::KeyValuePair<WTF::RefPtr<WTF::StringImpl>, WebCore::IdentifierRep*> >, WTF::StringHash, WTF::KeyValuePairHashTraits<WTF::HashTraits<WTF::RefPtr<WTF::StringImpl> >, WTF::HashTraits<WebCore::IdentifierRep*> >, WTF::HashTraits<WTF::RefPtr<WTF::StringImpl> > >::expand() C:\Qt\Qt5.1.1\5.1.1\mingw48_32\bin\Qt5WebKitd.dll 0×1dbbbd56
1 WebCore::IdentifierRep::get(char const*) C:\Qt\Qt5.1.1\5.1.1\mingw48_32\bin\Qt5WebKitd.dll 0×1d4c32b9
2 unuse_netscape_plugin_Plugin C:\Windows\system32\macromed\Flash\NPSWF32_11_8_800_94.dll 0×591e3de4
3 npswf32!Java_ShockwaveFlash_CurrentFrame_stub C:\Windows\system32\macromed\Flash\NPSWF32_11_8_800_94.dll 0×59bbcc84
4 ??
output:
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\platforms\qminimald.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\platforms\qoffscreend.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\platforms\qwindowsd.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\iconengines\qsvgicond.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\imageformats\qgifd.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\imageformats\qicod.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\imageformats\qjpegd.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\imageformats\qmngd.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\imageformats\qsvgd.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\imageformats\qtgad.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\imageformats\qtiffd.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\imageformats\qwbmpd.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\sensors\qtsensors_dummyd.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\sensors\qtsensors_genericd.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\bearer\qgenericbearerd.dll”
Temporarily disabling breakpoints for unloaded shared library “C:\Qt\Qt5.1.1\5.1.1\mingw48_32\plugins\bearer\qnativewifibearerd.dll”
STATS [10 requests total] [80.00% from cache] [0.00% pipelined] [0.00% SSL/TLS] [0.00% Zerocopy]
STATS [20 requests total] [90.00% from cache] [0.00% pipelined] [0.00% SSL/TLS] [0.00% Zerocopy]
STATS [30 requests total] [90.00% from cache] [0.00% pipelined] [0.00% SSL/TLS] [0.00% Zerocopy]
ASSERTION FAILED: !lookupForWriting(Extractor::extract(entry)).second
..\WTF/wtf/HashTable.h(952) : void WTF::HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::reinsert(WTF::HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::ValueType&) [with Key = WTF::RefPtr<WTF::StringImpl>; Value = WTF::KeyValuePair<WTF::RefPtr<WTF::StringImpl>, WebCore::IdentifierRep*>; Extractor = WTF::KeyValuePairKeyExtractor<WTF::KeyValuePair<WTF::RefPtr<WTF::StringImpl>, WebCore::IdentifierRep*> >; HashFunctions = WTF::StringHash; Traits = WTF::KeyValuePairHashTraits<WTF::HashTraits<WTF::RefPtr<WTF::StringImpl> >, WTF::HashTraits<WebCore::IdentifierRep*> >; KeyTraits = WTF::HashTraits<WTF::RefPtr<WTF::StringImpl> >; WTF::HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::ValueType = WTF::KeyValuePair<WTF::RefPtr<WTF::StringImpl>, WebCore::IdentifierRep*>]
could you help, please
p.s. sorry for my English
↧
Controlling the Drop-down Menu from a HTML tag
Hey there,
I’m trying to automate mouse input on a QWebView (subclass), which works pretty good. However, I am not able to send mouse events to the menu that’s created from a html <select> tag.
What I am trying to do:
I’m creating custom QMouseEvents that are sent to the QWebView. And the QWebView opens the <select>-menu if required.
If I send another QMouseEvent to the QWebView, nothing happens (i.e. nothing from the menu is selected).
I also tried to send the event to QApplication::activePopupWidget(). That will close the <select>-menu, but will not select an item. I thought the reason might be wrong coordinates, but that doesn’t seem to be the case.
In fact, I tried to “brute-force” find the correct coordinates to select something from the menu, but that diddn’t work. The menu always just closed.
Finally, I even tried to cast the activePopupWidget() to a QMenu*, hoping it would be a QMenu, but that doesn’t seem to be the case —> that made the application crash.
Long story short;
Is there any possible way to programmatically select an item from a HTML <select>-tag with QWebView?
Thanks,
Adrian
↧
Family safety
When Family safety (windows) is enabled, all links generated by my project in QT are rejected (blocked),
how do qnetwork/QtWebKit work with “Windows family safety”?
Thanks.
↧
↧
QWebview WebKit2 drag and drop does not work
Hi everybody
I have a problem that I hope somebody can shed some light on.
I have built Qt 5.1.1 for an embedded Linux device. I see the problem on several devices, and it doesn’t seem to be a device specific issue.
I have a simple QML application like the one shown here
https://qt-project.org/doc/qt-5.1/qtwebkit/qtwebkit-index.html
With this webview I don’t have drag support.
http://html5test.com/ shows no support for drag (Found under User Interaction)
With the demo at http://html5demos.com/drag I cannot drag items to the bin.
Dragging the list in the bottom of the FlickrView QML demo works.
If I use either the browser or fancybrowser examples to show http://html5demos.com/drag dragging works.
I hope somebody can give a clue as to why dragging works in the WebKit based demos, but not with a simple WebKit2 application.
Regards
Jesper
↧
Support for QWebView on Android
We are considering to use QT for developing cross-platform hybrid application that works on Windows, Linux, and Android. The idea is to build the application user interface using HTML/JavaScript pages and display the pages QWebView object hosted in native application. QT for Android was released as developer preview with QT 5.1 but it looks as QT for android does not include support for QWebView class in this release. Thus the question – do you plan to include support for QWebView in QT for Android. If yes, what is approximate time frame for making QWebView for android available?
Regards
↧
QWebFrame::findAllElements() doesn't work in separate thread
hi. i’m trying to parse webPage to get all links on it. i use a QThreadPool and my own class implementing QRunnable, which provides all fucntionality. Everything is going good, if I run such QRunnable in main thread, but
when I put my Runnable to the thread pool, QWebFrame::findAllElements(“a”) returns empty set. =(
———————————————————————————————————————
I run my Runnable:
in same thread, findAllElements() works perfect
webLoader()->run();
findAllElements() returns empty set =(
threadPool->start(webLoader);
————————————————————————————————-
I’ve already spent many hours trying to figure out problem. =(
*
*
*
Here is my code snippets:
webloader.h
class WebLoader : public QObject, public QRunnable
{
Q_OBJECT
QUrl url;
QString textPattern;
QWebPage* page;
public:
explicit WebLoader(const QUrl& url, const QString& textPattern);
void run();
virtual ~WebLoader();
signals:
void loaded(QList<QUrl> urls, bool error, bool found);
private slots:
void loadFinished(bool success);
};
webloader.cpp
WebLoader::WebLoader(const QUrl& url, const QString& textPattern): url(url), textPattern(textPattern) {
setAutoDelete(false);
}
void WebLoader::run() {
QEventLoop loop;
page = new QWebPage;
page->mainFrame()->load(url);
connect(page->mainFrame(), SIGNAL(loadFinished(bool)), SLOT(loadFinished(bool)));
connect(page->mainFrame(), SIGNAL(loadFinished(bool)), &loop, SLOT(quit()));
loop.exec();
}
void WebLoader::loadFinished(bool success) {
QList<QUrl> urlList;
bool found = false;
if(success) {
QWebElementCollection collection = page->mainFrame()->findAllElements("a");
foreach(QWebElement element, collection) {
if(element.hasAttribute("href")) {
urlList.push_back(url.resolved(QUrl(element.attribute("href"))));
}
}
found = page->findText(textPattern);
}
emit loaded(urlList, !success, found);
}
PS. sorry for my english.
↧
extract information from a website (HTML) using Qt ?
I’d like extract the “information” in the “b” tag => 123456789
this is the HTML sorce :
<body>
<div>
<table>
<tbody>
<tr>
<td class="myclass">
<b>123456789</b>
</td>
</tr>
</tbody>
</table>
</div>
</body>
so , i try this :
void My_Test_Dialog::on_pushButton_clicked()
{
QWebView *webview = new QWebView(parentWidget());
webview->load(QUrl("http://www.esesese.com"));
webview->show();
// get HTML element information
QWebElementCollection colls = webview->page()->mainFrame()->findAllElements("td.myclass b");
foreach(QWebElement elemento, colls)
{
ui->lineEdit_data->setText(elemento.toInnerXml());
}
}
i have a form with a Button(“call update”) and a LineEdit, so if i click on the “update” button , automatically the LineEdit should set the Text “123456789”. but my code doesn’t work .. the Text of the LineEdit remains Emply.
I include this :
#include <QtWebKit>
#include <QtWebKitWidgets/QWebFrame>
#include <QWebView>
QT file.pro is :
QT += core gui
QT += network
QT += webkit
QT += webkitwidgets
↧
↧
[Qt 5.1.1] QtWebView and QtWebpage not printing text when Qt built manually, but using QtCreator same code Works fine
Hi,
I am newbie to Qt.
Trying to generate basic pdf from html. I created project in QtCreator on ubuntu. When I run the resulting binary created by Qtcreator for my project on ubuntu, it works fine. I get the desired pdf with QWebView and QWebPage both printing text as well as images.
But ultimately we want to put this basic project on the Fedora based linux VM. In fedora, I took the Qt 5.1.1 source from http://download.qt-project.org/official_releases/qt/5.1/5.1.1/single/qt-everywhere-opensource-src-5.1.1.tar.gz and built Qt on that VM. The build runs fine and installs the Qt in usr/local/Qt directory
But taking my same project to that VM. I run:
1) qmake project.pro —-> which generates the Makefile for the project
2) Running Makefile creates binary for the project on the VM.
But when I run this binary on VM, if the html contains any text, the QPrinter does not print it in the final pdf. But, images are printed fine. * Tried both the QWebView and the QWebpage class, happening for both. *Happens only on VM, not locally.
Does anyone know, what I am missing? Code is below:
I installed QtCreator from here http://download.qt-project.org/official_releases/qt/5.1/5.1.1/qt-linux-opensource-5.1.1-x86_64-offline.run. Maybe if there a way I can install this on Fedora??? Since Fedora VM is all commandline, I dont need QtCreator there, but Qt5.1.1 libraries will do, as long as those libraries allow me to do qmake and build my project’s binary, i am good?? Let me know if I can go this way without building Qt on Fedora VM?
1 more thing:
While running the resulting binary of my project on VM, I ran into one more issue . Basically executing it caused
* QXcbConnection: Could not connect to display*. And the program will exit But I resolved this by installing xvfb-run
Running the executable in this fasion : xvfb-run —server-args=”-screen 0, 1024×768×24” ./h2p resolves the QXcbConnection problem. I wonder if the text not getting printed problem is not because of running the binary like this????
h2p.pro
#-------------------------------------------------
#
# Project created by QtCreator 2013-09-10T17:28:35
#
#-------------------------------------------------
QT += core webkit widgets webkitwidgets
QT -= gui
TARGET = h2p
#CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
MyPdfPrinter.cpp
HEADERS += \
MyPdfPrinter.h
main.cpp
#include <QApplication>
#include <QPrinter>
#include <QStyleOption>
#include <QtPlugin>
#include <QWebView>
#include <QFile>
#include <QPrinter>
#include <cstdlib>
#include <iostream>
#include "MyPdfPrinter.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
char *pdfFileName = "/home/rohit.chawla/Desktop/testPDF2StaticResourceImages_PAGES.pdf";
char *htmlFileName = "/home/rohit.chawla/Desktop/testPDF2StaticResourceImages_PAGES.html";
printf("Converting %s to %s\n",htmlFileName, pdfFileName);
QFile file(htmlFileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return 1;
QString text;
while (!file.atEnd()) {
text += file.readLine();
}
QWebView *qWebView = new QWebView();
qWebView->setMinimumSize(1024,768);
qWebView->show();
qWebView->setHtml(text, QUrl("file:///home/rohit.chawla/Desktop/resources/"));
MyPdfPrinter *myPdfPrinter = new MyPdfPrinter(qWebView , pdfFileName);
QObject::connect(qWebView, SIGNAL(loadFinished(bool)), myPdfPrinter, SLOT(receiveLoad(bool)));
return a.exec();
}
MyPdfPrinter.h
#ifndef MYPDFPRINTER_H
#define MYPDFPRINTER_H
#include <QApplication>
#include <QObject>
#include <QWebView>
class MyPdfPrinter: public QObject {
Q_OBJECT
private:
QWebView *qWebView;
char *pdfFileName;
public:
MyPdfPrinter(QWebView *webView , char *pdfFileName);
public slots:
void receiveLoad(bool);
};
#endif // MYPDFPRINTER_H
MyPdfPrinter.cpp
#include "MyPdfPrinter.h"
#include <stdio.h>
#include <QPrinter>
MyPdfPrinter::MyPdfPrinter(QWebView *webView , char *pdfFileName){
this->qWebView = webView;
this->pdfFileName = pdfFileName;
printf("\n Made Pdf Printer object\n");
}
void MyPdfPrinter::receiveLoad(bool isPrint){
printf("\nHere After loading\n");
QPrinter *qPrinter = new QPrinter(QPrinter::HighResolution);
qPrinter->setOutputFormat(QPrinter::PdfFormat);
qPrinter->setOutputFileName(pdfFileName);
this->qWebView->print(qPrinter);
printf("\n Exiting After printing pdf\n");
exit(0);
}
↧
Button onClick not firing for touchscreen devices
Using that latest Qt 5.1.2, a button onclick event is not firing when run on a Windows 8 touchscreen. Using Qt 5.0, it fires just fine.
To reproduce, just create the html5application test app and change your index.html to be this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body { margin: 0; font-size: 2em; background-color: white; }
h1 { text-align: center; color: red; }
h1 + h1 { color: green; }
h1:last-child { color: blue; }
#quit { background-color: gray; color: white; font-weight: bold; display: block; text-align: right; }
</style>
[removed]
var counter = 0;
function toggleElement()
{
var elements = document.getElementsByTagName('h1');
for (var i = 0; i < elements.length; ++i)
elements[i].style.display = (counter % elements.length) == i ? '' : 'none';
counter++;
setTimeout('toggleElement()', 1000);
}
window.onload = function()
{
document.getElementById("quit").onmousedown = function()
{
Qt.quit();
};
toggleElement();
}
function clicked()
{
alert("Clicked");
}
[removed]
</head>
<body>
<a id="quit">X</a>
<h1>Hello</h1>
<h1>HTML5</h1>
<h1>World</h1>
<p><button type="button" >Click Me!</button></p>
</body>
</html>
Works fine when compiled with 5.0 (you see the javascript alert when you touch the button) but nothing shows up on the tablet when compiled against the latest Qt.
↧
Rendering a page through webkit gives me a blue square with question mark; what precisely goes wrong?
I have a big chunky project that, as one of its many features, has some QML that renders a webpage. The webpage it renders is a standard webpage on the internet; nothing special.
When it renders it, a mysterious blue square with a question mark is seen. Rendering it with a standard browser shows nothing in that spot, so I look at the source and find something like this:
<!-- CANDDi http://canddi.com/privacy -->
[removed]
(function(){var a=document.createElement("script"),b=document.getElementsByTagName("script")[0];a.type="text/javascript";a.async=true;a.src=("https:"===document.location.protocol?"https://cdns":"http://cdn")+".canddi.com/p/5ed375bdc5625b876ce38f9e8c297567.js";b[removed].insertBefore(a,b);}());
[removed]
<noscript >https://i.canddi.com/i.gif?A=5ed335bdc5675b876ce35f9e8c297967</noscript>
<!-- /END CANDDi -->
Aha, I think. Looks like some kind of marketing company javascript. Presumably my QML browser is unable to deal with this and simply sticks a blue square with a question mark in place to let me know it’s been unable to handle this; although looking at it, whilst I don’t speak javascript, it looks like refusing to render the javascript should actually be met with sticking that gif, i.gif, there instead? I’d really like to know a bit more, though; can someone tell me what the problem is with a little more detail. I understand that the QML browser is a webkit browser? Is this some issue with webkit, or are there settings that I simply haven’t enabled, or some other such?
↧