Hi there!
I’m faced by very strange problem. I need to convert generated HTML-code into image. For that I use such code:
QPixmap img(imgWidth, imgHeight);
QPainter painter(&img);
painter.fillRect(img.rect(), Qt::white);
QBrush br(Qt::white);
QPen pn(Qt::black);
painter.setBackground(br);
painter.setPen(pn);
QWebView webView;
webView.setGeometry(0, 0, imgWidth, imgHeight);
webView.setHtml(content); // content - is given HTML-code
webView.page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
webView.page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
webView.page()->mainFrame()->render(&painter);
And it works fine …but. This HTML-code contains such content:
<img src="data:image/png;base64, ..." />
and this image is not displayed. For debugging reasons I created a window with QLabel and QWebView. QLabel is used to show pixmap, generated by the code, presented above. QWebView displays the content, used to generate the image. In other words, I use this window to compare the image, generated by my code, and the representation of the same HTML code by QWebView widget. I use two different buttons to update the pixmap in QLabel and to set the content in QWebView widget.
I found out very strange thing. When I press the first button, the QLabel displays the correct pixmap, but without embedded image. When I press the second button, QWebView displays the correct result with embeded image. If after that I press the first button again, the QLabel widget displays the pixmap with enbedded image.
In other words, QLabel displays correct pixmap with embedded image only if QWebView already displayed the same content earlier. It seems, QWebView activats something, what allows QWebView, used in my code (see above), to display the embedded image.
Any ideas?
Thank you in advance.
P.S. I use Qt v4.7.4.
Windows 7 x64
MinGW 4.4.0
↧
QWebView: strange problem with embedded images
↧
QML WebVew (QtWebKit 3.0) shows content zoomed out, until dbclick.
Hi. Here is my problem. QML WebVew shows content zoomed out, until dbclick. But how can I make it 100% scale immediately after loading?
↧
↧
How to Pinch zoom in the browser using the QtWebkit?
I’d like to support Pinch zoom in the browser using the QtWebkit.
There is a (Qtwebkit-examples/examples/webkitwidgets/browser) sample browser to sources of Qt5.1.1 .
This browser does not seem to support the Pinch Zoom.
(This browser is supported zoom with [crtl] key + mouse wheel. But Pinch zoom(used two finger) not supported)
Doesn’t someone learn how to support Pinch Zoom?
↧
Url works under windows but no under Linux (QWebView)
Hi all,
I have a trouble with QWebView. When i load this page https://desktop.pingone.com/, it works under windows but no under linux.
I use qt 5.1.1 for both, i do not have any ssl errors on Linux.
Thanks for reply.
↧
QML to develop HTML
Hi Everyone!
I have a very newbie level question, so please bear with me. I am GPGPU programmer mainly adept with C++ and OpenCL (and OpenGL), and as unfortunate as my fate is, I am bound to develop and maintain a website of my own. (Unfortunate not because web developing is not glorious enough for my taste, but because I am just one man, who can only accomodate as much experience, and I know that a skilled web developer could do a hell of a lot better job at it, than I can.) I have learned the basics of HTML and CSS, and have put together a simple website [gpu.wigner.mta.hu] that is on the verge of me daring to give a link to it. (English translation is on the way, right now you can navigate through it in Hungarian, as only the main page is translated.)
Anyhow… Since I have been aiming to shift my widget based OpenGL application to QML and making use of Quick Components (if that’s the correct name for it) to give it that ‘dektop’ feel, I was wondering if it were possible to recycle the time put into learning QML and develop a simple, somewhat static website in QML, and export it somehow to HTML and JS.
I have found this thread [qt-project.org] thread but my knowledge is not enough to tell if this is what I’m looking for or not. Currently I’m developing using Microsoft Expression Web 4, but the sole biggest feature I use it for is templating my pages.
I was wondering if it were enough if I need only master one high-level UI (QML) language instead of three (QML, HTML, CSS) to do all my work. I am only one person, and my mind is limited, therefore I would not like to stuff it with redundant lexical knowledge. Can I do both GUI applications and webpages in solely QML?
↧
↧
Mac OSX qt5 Become a Native PrintDialog on QWebView
I have the trackpad QTouchEvent screen zooming on my mac and no printer support.. :-(
I try from old qt4 sample code and other stuff or demo.
Is this a mac problem?
void BigFox::printPwd() {
#ifndef QT_NO_PRINTER
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFileName("");
QPrintDialog pp(&printer,this );
int resultofexec = pp.exec();
#endif
//// FOXBEEP() << resultofexec << ":" << __FUNCTION__ << " your eye doctor like zoomss..";
}
bool BigFox::event(QEvent * ev) {
const int nr = ev->type();
switch (ev->type()) {
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
{
QTouchEvent *touchEvent = static_cast<QTouchEvent *> (ev);
QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
if (touchPoints.count() == 2) {
const QTouchEvent::TouchPoint &TpointA = touchPoints.first();
const QTouchEvent::TouchPoint &TpointB = touchPoints.last();
const qreal linedistance = QLineF(TpointA.pos(), TpointB.pos()).length(); //// 1111
const qreal linestartpos = QLineF(TpointA.startPos(), TpointB.startPos()).length(); //// 222
bool zoomIn = false;
const qreal oldFaktorNow = zoomFactor();
/// ZOOMMAX = 500%
qreal xmax = qMax(linedistance, linestartpos);
const qreal ticks = ((ZOOMMAX / 5) / 100) * PERCENTZOOMSTEEPS; /// up down by 8%
//// is zoom in or out ?
const qreal goZoomFaktor = (linedistance == xmax) ? oldFaktorNow + ticks : oldFaktorNow - ticks;
//// if fingers go out save new state
if (touchEvent->touchPointStates() & Qt::TouchPointReleased) {
ZoomNewValue(goZoomFaktor);
}
}
}
default:
break;
}
return QWebView::event(ev);
}
#include "main.moc"
/* qmake pro qt5 file xx
TEMPLATE = app
DESTDIR = ./
TARGET = xx
QT += network webkitwidgets core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
## bundle at end..
CONFIG -= app_bundle debug
CONFIG += qt warn_off silent debug console
cache()
*/
↧
QWebView 4.8 on windows
I am using Qt 4.8. I successfully compiled application using QWebView on linux. After this I converted .pro file to Visual Studio 2010 project using qmake and compiled on windows. When I run on windows nothing works – the QWebView is always blank. Does it work on windows? May be I didn’t copy required dll files into application’s folder? I compiled windows application same way before and it worked well but it didn’t use webkit.
↧
Embedded object not loaded when "display:none" style property is added
Hi all,
my application (on linux desktop for now) is based on Qt 4.8 and displays a web page using the Webview object. I also have an NPAPI plug-in to handle objects like
<object type=“myplygintype”></object>
Everything works fine and my plug-in gets called to create such objects as expected until I add
style=“display: none”
to the object tag, in which case it seems that the object is not loaded at all and the browser doesn’t call my plug-in.
At http://www.w3schools.com/jsref/prop_style_display.asp it is said “display:none hides an element, and it will not take up any space. The element will be hidden, and the page will be displayed as if the element is not there”, therefore I would expect my plug-in to be called for the creation of the object. Is my understanding correct?
Is there a bug or it is the expected behaviour?
Thank you
↧
Force URL in QWebView
Hi,
I’d like to force domain loaded in QWebView.
i.e. if the url doesn’t start by “http(s)://www.domain.xxx”,
=> then abort and load “http(s)://www.domain.xxx”
For example, I tryed like this:
connect(view, SIGNAL(urlChanged(QUrl)), SLOT(forceDomain()));
// ...
void MainWindow::forceDomain()
{
QString loc = view->url().toString();
if ( !loc.startsWith("http://www.domain.xxx") )
{
QUrl url = QUrl("http://www.domain.xxx");
view->load(url);
view->setFocus();
}
}
But it seems the code is looping (?)
The application fail with code “1073741819”
Any suggestion?
Thx, Cedric
↧
↧
Compile Qt5.x + webkit without mmx support
Hi,
In previous version of qt (4.x), one can configure qt with option -no-mmx. In newer versions, that option is no longer applicable. I have been mucking around the source code and couldn’t find a way to disable MMX support. Please let me know if there is a way to disable multi-media instructions (MMX) in qt5 and also webkit. Thank you.
toan
↧
comment mettre en ligne un tutoriel crée avec Qt
Bonjour, je suis une débutante dans le langage C++ et Qt, je viens de créer avec Qt un tutoriel interactif sur les calculs de doses (pour des étudiants en soins infirmiers). Au fur et à mesure, il y a des questions auxquelles l’étudiant peut répondre et vérifier si ses réponses sont correctes.
Je souhaite maintenant que les étudiants puissent y avoir accès en ligne et je ne sais pas comment faire car sur le site de l’école on ne peut mettre que des PDF (et encore pas trop volumineux) par ailleurs le service informatique m’a fait comprendre qu’il ne pouvait rien faire pour moi, donc je cherche un moyen d’héberger mes programmes (gratuitement) de telle sorte que je n’ai plus qu’à communiquer aux étudiants le lien correspondant au tutoriel pour qu’ils puissent s’exercer.
Merci de me dire ce que vous en pensez et ce que je peux faire.
Nadska
↧
ENABLE_VIDEO and ENABLE_MEDIA_SOURCE in QtWebkit2.3
HI all,
I’m trying to build QtWebkit2.3 (download from https://gitorious.org/webkit/qtwebkit-23) for Qt4.8 in a linux OS.
I have run the build script as follows:
Tools/Scripts/build-webkit —qt —media-source —media-capture —video —no-webkit2 —no-force-sse2 —no-xslt
I tested with http://html5test.com/ page.
Result: – does not load the html5test.com page. It show loading icon on the screen.
Please help.
↧
qt5.2 webview html5 drag&drop failed
i write a webpage with image drag and drop from a img tag to div…it works fine in chrome and other browser..with Qt4.8.4 webview it works fine too..but with qt5.2.0 webview it failed…i don’t kown why. does anyone can fix this problem….thanks
↧
↧
Qt Project with Cocoa Webview got a compilation error
Since Mac App Store doesn’t accept Qt webkit apps, I am trying to use webview of Cocoa in my Qt app. The problem is I failed to compile it with Qt5.1.1, but successful with Qt5.2.0, However, I cannot use Qt5.2.0 for some reason, so how to fix it , you can get my demo here [drive.google.com]
↧
[Solved]WebView can't load flash plugin to play swf file
hi
I have stuck with this flash problem for days,my environment is
windows 7 64bit,
Qt5.2 32bit,
adobe flash player 11 32bit
and my code is like these:
WebView {
id: testWebViewJs
anchors.fill: parent
url: "http://helpx.adobe.com/flash-player.html"
experimental.preferences.pluginsEnabled: true;
experimental.preferences.javascriptEnabled: true
onUrlChanged: {
console.log(testWebViewJs.url);
}
}
It display html pages as well,but flash object didn’t showed up,it shows a little icon like this:
I thought the flash plugin was not loaded,but i don’t know why.
any suggestion will be helpful,thanks.
↧
Get data from webpage upon clicks on links
Hi
I have a webpage used as GUI. The contents of the page is filled with dynamic data from an SQL server by the php scripts in the webpage.
When the user clicks a certain link I need to get the data “hidden” in the link (multiple strings) that the webpage gets from the SQL server upon the click and have this data in C to further use it.
How can I achieve this?
Thanks
McL
↧
Qt5 QWebView not properly responding to touch events
I’m using a simple kiosk web browser called WCGBrowser [github.com] written in PyQt5 using a QWebView, running on a Debian Testing machine with Qt5 version 5.1.1. The computer’s only input device is a Quanta multitouch touchscreen, which is supported by the Evdev driver and works perfectly in most applications.
However, when touching links, buttons, or other elements in a web page, the element visually responds as if it’s been clicked, but doesn’t perform it’s associated action. For example, when on Google’s homepage, tapping the search button shows the button being depressed, but doesn’t actually change to the search page. Using a regular mouse on the same instance works as expected.
My quick fix was to override the event method of the QWebVew to reject touch events, causing QT to generate mouse events instead. However, the mouse emulation doesn’t work very well, users often accidentally select text or have other related issues. I’d like to get proper touch support working instead.
This doesn’t appear to be PyQt5 bug, it’s either a QT bug or (somewhat more likely), a bug in the kiosk browser I’m using. I’ve done what debugging I can, does anyone have suggestions for what I can try to discover what’s causing the problem? I’m a fairly experienced Linux user but new to QT, I’m fine with compiling QT devel if needed.
↧
↧
QtWebKit interim files and release doesn't get created in specified OUTPUT directory
I am building qtwebkit 2.3 with commandline as,
WEBKIT_OUTPUTDIR=`pwd`/qt485-rpi-qpa ../qtwebkit-23/Tools/Scripts/build-webkit —qt
I am expecting it to create interim files and release output in `pwd`/qt485-rpi-qpa but it doesn’t do that .. any clue?
↧
QtWebKit rotates glyphs in vertical layout
Hi Everyone,
I would like to render Asian scripts in vertical mode. The WebKit version in PySide 1.2.1 (which we currently use) is AppleWebKit 534.34 does rot rencer it correctly. Even PyQt5 (5.1.1) AppleWebKit 537.21 has the same issue.
A recent Chrome browser renders this fine. This is what it should look like:
Nice example [dl.dropboxusercontent.com]
When I render through Qt/Webkit, it comes out with all glyphs rotated 90 degrees to the right.
Is there any way to fix this?
Example:
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Created on Jan 8, 2014
@author: PA
'''
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtWebKit import *
content = r'''
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<title>Japanese vertical layout example</title>
<style>
html {
font-size: 10px;
width: 100%;
}
body {
font-size: 1.5rem;
background-color: #eee;
}
article {
width: 1280px;
margin: 2rem auto;
padding: 5rem 0;
background-color: white;
box-shadow: 0 0 5px silver;
font-family: "Meiryo", sans-serif;
color: #555;
}
header {
width: 100%;
height: 34rem;
margin-bottom: 8rem;
background-image: url("https://dl.dropbox.com/u/444684/OpenWebDemos/css3writingModes/images/2752501599_bdfb7a9258_b.jpg");
background-size: 100% auto;
-ms-writing-mode: tb-rl; /* old syntax. IE */
-webkit-writing-mode: vertical-rl;
-moz-writing-mode: vertical-rl;
-ms-writing-mode: vertical-rl;
writing-mode: vertical-rl; /* new syntax */
}
h1 {
text-shadow: 0 1px 1px grey;
color: white;
font-weight: bold;
font-size: 3rem;
padding: 11rem 12rem 0 0;
}
section {
-ms-writing-mode: tb-rl; /* old syntax. IE */
-webkit-writing-mode: vertical-rl;
-moz-writing-mode: vertical-rl;
-ms-writing-mode: vertical-rl;
font-size: 1.2rem;
margin-left: 5rem;
height: 30rem;
}
section p {
text-indent: 1.3rem;
margin: 0;
text-align: justify;
}
footer {
margin: 0 auto;
width: 1280px;
color: grey;
}
</style>
</head>
<body>
<article>
<header>
<h1>八幡平</h1>
</header>
<section>
<h2>特徴</h2>
<p>国立公園八幡平地域は40,489haの広さがあり、ほとんどが国有林である。手つかずの山岳公園で、アオモリトドマツやブナの原生林、山稜、湿原、噴気などの自然環境に多用な動植物が形成されている。</p>
<p>およそ100万年前に噴出したいくつかの火山でできている。山頂部のなだらかな様子から楯状火山とされていたが、現在では山頂が台地状になった成層火山だといわれている。頂上部には9千~5千年前に発生した水蒸気爆発により多くの火口ができている。その火口に水がたまり、八幡沼やガマ沼、メガネ沼などの沢山の火口沼が作られている。周囲には広大な湿原や針葉樹林帯が形成されている。</p>
<p>伝説によると、桓武天皇の勅命で奥州蝦夷征伐に訪れた坂上田村麻呂は、山賊の残党を追う途中に八幡平にたどり着き、その極楽浄土のような景色に感激した。そこで、戦の神である八幡神宮を奉り戦勝を祈り、残党を討伐後に再度高原の八幡神宮を訪れ、戦勝の報告を行うとともに、この地を「八幡平」と名付けたとされる。ただ、史実では坂上田村麻呂はこの地には至っていない。</p>
<p>八幡平一帯は地形がゆるやかで、残雪が豊富なことから沼や湿原が多い。湿原にはさまざまな高山植物や湿原植物の群落が発達している。
</p>
<p>八幡平山頂には二等三角点がある。あまりに平らで山頂らしくないということで、1962年に岩手県によって土盛りが行われた。それが崩れてきたので、1986年に国立公園指定30周年を記念して現在の展望台が作られた。展望台は老朽化のために、2012年11月に建て替えられた。</p>
<p>1993年に頂上付近の見返峠の駐車場で料金徴収が開始された。これは、有料道路であった八幡平アスピーテラインの無料化と松川温泉と藤七温泉を結ぶ樹海ラインの開通により、利用者の急増に対応するために、利用者に自然を守るための応分の負担を求めるためである。駐車料金は、公園施設の維持管理と美化清掃などの費用として使われている。</p>
</section>
</article>
<footer>
<small lang="en">Text taken from the Japanese Wikipedia article for <a href="http://ja.wikipedia.org/wiki/八幡平" hreflang="ja">Mount Hachimantai</a>. Image <a href="http://creativecommons.org/licenses/by-nc-sa/2.0/">by-nc-sa</a>, some rights reserved by <a href="http://www.flickr.com/photos/jasohill/2752501599/sizes/l/in/photostream/">jasohill</a>.</small>
</footer>
</body>
</html>
'''
app = QApplication(sys.argv)
web = QWebView()
web.setContent(content)
web.show()
sys.exit(app.exec_())
↧
Qt5, eglfs, WebKit2 ,Qml and Snowshoe
hi there
I’ve been playing around with getting a browser with proper WebGL support to run on my i.IMX6Q target.
I have already tried the browsers from qt5 examples, i.e. browser and fancybrowser. The site html5test.com [html5test.comhtml5test.com] reports that they are supporting 394 out of 555 HTML5 elements so it seems pretty compliant.
This browser is suppose to support WebGL according to html5test.com but when running some WebGl tests on webgltests [code.google.com] it fails miserably because the performance is so bad it can’t manage to keep up a good framerate. The kernel module for the accelerator on the target seems to be in use at the same time so I guess it is doing some acceleration !!
But I have started to wonder if these browsers are using WebKit2 at all ? and how they then could be supporting WebGL if using WebKit1. Is WebKit1 supporting WebGL ? I was under the impression it didn’t.
So I went on and cross-compiled the snowshoe browser which is using WebKit2 and tried to run that on my target. It does execute after I have declared QML2_IMPORT_PATH but the screen is very small and there are some errors being printed out on the console:
<Unknown File>:
Inspector server started successfully. Try pointing a WebKit browser to http://127.0.0.1:9222
qrc:///qml/UrlBar.qml:63:5: QML Connections: Cannot assign to non-existent property "onLoadingChanged"
qrc:///qml/PageWidget.qml:275:13: QML PropertyChanges: Cannot assign to non-existent property "visible"
qrc:///qml/PageWidget.qml:279:13: QML PropertyChanges: Cannot assign to non-existent property "visible"
qrc:///qml/PageWidget.qml:283:13: QML PropertyChanges: Cannot assign to non-existent property "url"
qrc:///qml/main.qml:119:13: QML PropertyChanges: Cannot assign to non-existent property "visible"
qrc:///qml/main.qml:123:13: QML PropertyChanges: Cannot assign to non-existent property "visible"
<Unknown File>:
I have also tried MiniBrowser but it behaves the same as snowshoe.
My questions are:
1) Is there anybody with some insight into how to run a proper browser using -platform eglfs ?
2) Do I have to explicitly declare something on the configure line to enable WebKit2 when compiling Qt5 ?
3) Can I have the 2D canvas accelerated ?
4) Is there another browser more suitable for the task of running html5/canvas with WebGL support ?
Regards
Einar
↧