Re: [Interest] Pause QTableView while model continues to update

2020-07-09 Thread Francis Herne
On Thursday, 9 July 2020 14:58:05 BST Francis Herne wrote:
> On Wednesday, 8 July 2020 19:20:33 BST Murphy, Sean wrote:
> > Is there a way to temporarily pause a QTableView while the underlying
> > model
> > continues to update?
> > 
> > My scenario:
> >  - I have two separate QTableViews connected to a single model.
> >  - The model is being fed from a continuously updating data source, i.e. a
> > 
> > sensor. - One of the views needs to remain live at all times - so as the
> > model's data updates, the view updates immediately.
> > 
> > For the other view, the user should be able to "pause" that view's
> > display,
> > spend as much time as they want looking at the data on that paused table,
> > and then whenever they choose, they can un-pause that view and it returns
> > to updating constantly. This view has to remain fully usable (scroll bars
> > work, clicks work, etc.) while paused.
> > 
> > The only idea I have at the moment is to have a second model object, that
> > is identical to the first one, except that it isn't connected to the
> > sensor. At the time the user wants to pause the view, I copy the current
> > data out of the main model into the second model, swap out the paused
> > view's model out to the second model, and then swap it back to the main
> > model when the user wants to go back live.
> > 
> > Am I missing something easier? The only other idea I had was that I could
> > try to change the second view from a pure QTableView to one that inherits
> > from QTableView and then have my own slot that disconnects/connects the
> > signals between the model and that view based on the when the user wants
> > to
> > pause/resume.
> > 
> > Sean
> 
> You could have a QProxyModel subclass with a 'timeRange' (or so) property.
> 
> When set to null it would simply relay everything to the backing model,
> otherwise it would provide only the relevant subset.
> 
> I think this would be much easier than copying the data, or swapping models
> in and out.
> 
> -Francis H

To be more precise - you should subclass QSortFilterProxyModel and override 
`filterAcceptsRow()` and/or `filterAcceptsColumn()` to hide data outside the 
time period you want.


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Pause QTableView while model continues to update

2020-07-09 Thread Francis Herne
On Wednesday, 8 July 2020 19:20:33 BST Murphy, Sean wrote:
> Is there a way to temporarily pause a QTableView while the underlying model
> continues to update?
> 
> My scenario:
>  - I have two separate QTableViews connected to a single model.
>  - The model is being fed from a continuously updating data source, i.e. a
> sensor. - One of the views needs to remain live at all times - so as the
> model's data updates, the view updates immediately.
> 
> For the other view, the user should be able to "pause" that view's display,
> spend as much time as they want looking at the data on that paused table,
> and then whenever they choose, they can un-pause that view and it returns
> to updating constantly. This view has to remain fully usable (scroll bars
> work, clicks work, etc.) while paused.
> 
> The only idea I have at the moment is to have a second model object, that is
> identical to the first one, except that it isn't connected to the sensor.
> At the time the user wants to pause the view, I copy the current data out
> of the main model into the second model, swap out the paused view's model
> out to the second model, and then swap it back to the main model when the
> user wants to go back live.
> 
> Am I missing something easier? The only other idea I had was that I could
> try to change the second view from a pure QTableView to one that inherits
> from QTableView and then have my own slot that disconnects/connects the
> signals between the model and that view based on the when the user wants to
> pause/resume.
> 
> Sean

You could have a QProxyModel subclass with a 'timeRange' (or so) property.

When set to null it would simply relay everything to the backing model, 
otherwise it would provide only the relevant subset.

I think this would be much easier than copying the data, or swapping models in 
and out.

-Francis H


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] how do I load massive table views instantly?

2020-06-08 Thread Francis Herne
On Friday, 5 June 2020 17:23:37 BST David M. Cotter wrote:
> >>> What table view are you talking about, specifically?
> >> 
> >> QTableView with QSortFilterProxyModel
> > 
> > What is the model _behind_ QSFPM?
> 
> i'm trying to understand your question. i'm not sure what you mean, cuz i'm
> not the SQLite dev what i know is that each song has a couple dozen bits of
> data (name, artist, album, several file paths, rating, duration etc etc)
> besides that, what are you asking?=

QSortFilterProxyModel is a *proxy* that makes other models sortable.  it only 
works when its `sourceModel` property is set to an instance of a different 
model class that actually contains the data.


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Qt Creator licensing for companies with Qt Commercial developers

2020-03-31 Thread Francis Herne
> ...
>
> Example 6: Company I is building two independent products with separate
> development teams. One development team uses Qt under commercial license to
> create product 1 and the other development team uses Qt under open-source
> license to create product 2. This is ok.
 
> Hopefully I was able to clarify the topic with these examples. The Qt
> Company wants to provide Qt under open-source license. There is no mega
> corporation with deep pockets behind. Development of Qt is funded with the
> revenues gained from commercial licensing.
 
> Yours,
> 
> Tuukka

Dear Tuukka,

Thank you for the clear examples.

If I'd seen this email before writing my previous one, it would have been less 
grouchy!

That said, could you explain how Example 6 is permitted under the licensing 
terms, given the section I quoted in the other email which appears to prohibit 
this without allowance for separate projects?

Thanks again,
 - Francis H


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Qt Creator licensing for companies with Qt, Commercial developers

2020-03-31 Thread Francis Herne
On Tuesday, 31 March 2020 18:02:15 BST Tuukka Turunen wrote:
> Hi,
> 
> I apologise, if I have been unclear with words 'company' and project'. If
> you read the license agreement and faq behind the links I have posted
> multiple times, it should be rather clear what is meant. 
 
> Yours,
> 
>   Tuukka

Dear Tukka,

Frankly, I think you're arguing in bad faith here. It's patently obvious from 
every response in this thread that the Qt Company's position is *not* clear to 
anyone outside the company.

The FAQ doesn't address the project/company distinction at all, and linking 
20,000 words of legalese in "answer" to a boolean question is just a refusal 
to give a straight answer.

Having looked through said document, the relevant sections seem to be:

> 1. ... “Prohibited Combination” shall mean any means to (i) use, combine, 
incorporate, link or integrate Licensed Software with any software created 
with or incorporating Open Source Qt, (ii) use Licensed Software for creation 
of any software created with or incorporating Open Source Qt, or (iii) 
incorporate or integrate Applications into a hardware device or product other 
than a Device. ...

Can't use licensed Qt Creator to develop open-source Qt apps; ok.

> 3.4 [viii]: Licensee shall not and shall cause that its Affiliates or 
Contractors shall not use Licensed Software in any Prohibited Combination, 
unless Licensee has received an advance written permission from The Qt Company 
to do so.

Can't use licensed and GPL Qt in the same project; ok.

> Absent such written permission, any and all distribution by the Licensee 
during the Term of a hardware device or product a) which incorporate or 
integrate any part of Licensed Software or Open Source Qt; or b) where the 
main user interface or substantial functionality is provided by software built 
with Licensed Software or Open Source Qt or otherwise depends on the Licensed 
Software or Open Source Qt, shall be considered to be Device distribution 
under this Agreement and shall be dependent on Licensee’s compliance thereof 
(including but not limited to obligation to pay applicable License Fees for 
such distribution).

It's unclear here whether this should be read as "hardware (device or 
product)" or "(hardware device) or product". Could you please clarify the 
intent?

Taking the latter, more pessimistic reading there's no project/company 
distinction; any entity licensing Qt can't distribute the GPL version in any 
'product' which I believe would include open-source projects. Hard luck Thiago 
et al!

> Notwithstanding what is provided above in this sub-section (viii), Licensee 
is entitled to use and combine Qt 3D Studio and/or Qt Design Studio with Open 
Source Qt (“Permitted Combination”) for its internal evaluation purposes, 
provided that Licensee shall in no way transfer, publish, disclose, display or 
otherwise make available any software or work resulting from such Permitted 
Combination;

This exception doesn't cover Qt Creator, and would be in the opposite 
direction to the original question anyway.


So the answer is "no".

In general, the only "clear" policy is that The Qt Company deliberately 
obfuscates the conditions under which the GPL version can be used, to put 
people off exercising the rights that do exist.

This goes along with the general downplaying of, and FUD about, the GPL option 
on the website, and the bizarre retrospective licensing.

It's disrespectful to the outside contributors who've built so much of Qt and 
its ecosystem in exchange for those rights, and doesn't bode well for the 
future of Qt in the free software community.

Yours,
-Francis H


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Qt5.14 & Android-NDK

2020-03-28 Thread Francis Herne
On Saturday, 28 March 2020 18:13:15 GMT Marc Van Daele wrote:
> Hello,
> 
> I'm trying out Qt5.14.1 for Android (the app bundle feature) and I get an
> error like
> 
> ../../../Qt/5.14.1/android/include/QtCore/qglobal.h:45:12: fatal error:
> 'type_traits' file not found
> Upgrading from NDK r19c to NDK21.0 compiles just fine.
> 
> Is it somewhere documented which NDK is required for a give Qt version?
> 
> Kind Regards,
> 
> Marc

The changelog for Qt 5.14 documents this:

https://doc.qt.io/qt-5/whatsnew514.html#platform-changes

> Platform Changes
> Android now requires NDKr20+.

-Francis


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Zooming with QGraphicsView/QGraphicsItem

2019-08-08 Thread Francis Herne
You should definitely look at QGIS:
https://qgis.org/en/site/index.html

It's open-source and has an excellent map-rendering implementation including 
shapefile support.

-Francis H


 Original Message 
From: Israel Brewster 
Sent: 8 August 2019 16:55:49 BST
To: Brad Pepers 
Cc: Interest 
Subject: Re: [Interest] Zooming with QGraphicsView/QGraphicsItem

I do have .shp files for the coastlines - perhaps I could convert those to 
something I could use? If I can get vector data, how would I go about utilizing 
it?

I played around a bit with loading different image files, but so far the 
performance has been unacceptable - the entire app locks up for several seconds 
when displaying the higher resolution images. I think Vector would be a better 
way to go, if I can figure out how. Thanks!
---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145

> On Aug 7, 2019, at 10:12 PM, Brad Pepers  wrote:
> 
> In the end the answer is to get the coast as vector data instead of a raster. 
> The raster is going to be at a fixed map scale and any scale above or below 
> is going to extrapolate or interpolate the results eventually ending in poor 
> results because there just isn’t the information needed or too much 
> information is being lost. Having different resolutions should help and you 
> can keep multiple levels and switch between them at appropriate times (LOD). 
> Those are your best bets if you can’t get the actual vector data!
> 
> --
> Brad
> 
> 
> On Aug 7, 2019, at 12:01 PM, Israel Brewster  > wrote:
> 
>> I have a QGraphicsScene/QGraphicsView that I am using to display a map (and 
>> some data). The map is in the mercator projection, with the x and y 
>> coordinates of the scene corresponding to map coordinates, so the background 
>> images are rather large. Images are loaded into a QGraphicsObject which is 
>> then added to the scene. The object types are defined by a third-party 
>> library, so I don’t have the option of using different objects, such as 
>> QGraphicsPixmapObject or something.
>> 
>> This works fine when I’m zoomed in to the map. Coastlines are nice and 
>> sharp, with no issues:
>> 
>> 
>> However, when I zoom out, the coastline becomes quite pixelated, and 
>> difficult to see in places:
>> 
>> 
>> How can I fix this? My first thought was to change the size of the 
>> background image so it could scale better, but that didn’t seem to help. In 
>> retrospect, this makes sense: at the end of the day, the background image 
>> has to be the correct size for the mercator projection, so while I can 
>> certainly change the pixel density, the overall size, and thus how much 
>> scaling is needed to display a given area, is fixed.
>> 
>> ---
>> Israel Brewster
>> Software Engineer
>> Alaska Volcano Observatory 
>> Geophysical Institute - UAF 
>> 2156 Koyukuk Drive 
>> Fairbanks AK 99775-7320
>> Work: 907-474-5172
>> cell:  907-328-9145
>> 
>> ___
>> Interest mailing list
>> Interest@qt-project.org 
>> https://lists.qt-project.org/listinfo/interest 
>> 

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] sizeHint for delegates not wqorking

2018-07-03 Thread Francis Herne
On Tuesday, 3 July 2018 03:11:42 BST Frank Rueter | OHUfx wrote:
> Hi all,
> 
> I am having trouble controlling my table view’s column sizes.
> I thought implementing the delegate’s sizeHint was a way to do this but
> it won’t work for me.
> 
> Can somebody please point out what I’m missing?

You must also set an appropriate resize mode for the view.

Adding
`self.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)`

to MyView.__init__ should solve your problem.

See http://doc.qt.io/qt-5/qheaderview.html#ResizeMode-enum

-Francis


___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt 5.8 qt3d examples not working on Raspberry Pi 3

2017-03-01 Thread Francis Herne
On Wed, 1 Mar 2017 00:40:49 +
Pierre Chicoine  wrote:

> Qt3d 5.8 examples are not working on Raspberry Pi 3 using Raspbian
> Jessie. I'm using the latest Raspberry PI toolkit not Yocto. Should I
> use a different board?
> 
> I've tried all GL driver modes in raspi-config. The current VC4 driver
> doesnt' work. Strangely enough, the Raspberry PI works with
> qopenglwidget so opengl examples works but not QT3d. I was going to
> try to compile the fragment shaders directly but I can't find a
> fragment shader that even has 41 lines of code in the Qt3d toolkit.
> (Refer to error below).
> 
> I'm asking this sincerely, I know that KDAB is not technically
> responsible and you've done a great job getting Qt3d working on
> desktop. The code looks like a very capable toolkit.
> 
> Sean, are you planning on supporting the Raspberry PI? I've been
> trying to implement Qt3d since before Qt 5.7 when it was officially
> supported and I've tried everything to no avail. Anholt's work on the
> Raspberry drivers don't work and the legacy drivers don't work so I'm
> seriously thinking about giving up several months of work, removing
> all the work I did to get OpenGl working with Qt3d which will take
> several month to untangle. I really don't know what to do from here.
> 
> Please let us know if it is supported or will be and if it or will
> be, is what is the magic used to get it working.
> 
> This is the error returned on the command line (this works just fine
> on desktops):
> 
> No Input Settings found, keyboard and mouse events won't be handled
> Trying to assign a non shareable component to more than one Entity
> QOpenGLShader::link: ERROR:OPTIMIZER-3 (fragment shader, line 41)
> Support for for loops is restricted : right side of condition
> expression must be constant
> Failed to link shader program: ERROR:OPTIMIZER-3 (fragment shader,
> line 41) Support for for loops is restricted : right side of
> condition expression must be constant

Are you sure you're using the mesa vc4 driver (and not Broadcom's
driver for the VideoCore IV chip) ?

The error message you mention is part of Broadcom's firmware-wrapper
code, and afaict doesn't exist in Mesa.

(https://github.com/shacharr/videocoreiv-qpu-driver/blob/master/brcm_usrlib/dag/vmcsx/middleware/khronos/glsl/glsl_ast.c#L3035)

-Francis
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] How to paint smooth rendering of connected QLineF's?

2017-02-28 Thread Francis Herne
On Tue, 21 Feb 2017 02:17:24 -0800
Patrick Stinson  wrote:

> Hello!
> I am painting a series of connected QLineF's with varying vectors and
> widths. Is there any way to smooth them out to be more vector-ish, so
> you don't see the jagged transitions between the segments?
> 
> This is for hand writing notes with the Apple Pencil. I have one
> segment per event with pressure determining width and it just looks
> so jagged now...
> 
> Thanks!

QSplineSeries from Qt Charts (http://doc.qt.io/qt-5/qsplineseries.html)
solves the same problem, but unfortunately it doesn't seem to be very
generalised.

Perhaps you could take the relevant parts of its implementation, which
seem to be calculateControlPoints(), updateGeometry() and paint() in

http://code.qt.io/cgit/qt/qtcharts.git/tree/src/charts/splinechart/splinechartitem.cpp

-Francis
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] How to really delete a QGraphicsItem from QGraphicsScene

2017-02-24 Thread Francis Herne
On Fri, 24 Feb 2017 19:12:18 +0800
jack ma  wrote:

> Hi,
> 
> is it correct to use “delete” directly delete the item ?
> 
> or I should first call removeItem() and then call "delete item"  to
> remove it?
> 
> How are these two ways affect the bsp tree?
> 
> Thanks,
> jack

From the docs for ~QGraphicsItem():

> Destroys the QGraphicsItem and all its children. If this item is
> currently associated with a scene, the item will be removed from the
> scene before it is deleted.

> Note: It is more efficient to remove the item from the QGraphicsScene
> before destroying the item.

So either method is safe, but explicitly removing it is better.


-Francis
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt5.8 qt3d examples not working

2017-02-22 Thread Francis Herne
On Tue, 21 Feb 2017 10:41:04 +0100
"Lukáš Sedláček"  wrote:

> Hello,
> 
> I have just got my Raspberry Pi3 (using raspbian lite without pixel - 
> only linuxfb/eglfs) and I am having problems to run Qt3d examples
> (which will be very useful to for me). I cross compiled Qt5.8 library 
> downloaded from download.qt.io using this tutorial 
> https://wiki.qt.io/RaspberryPi2EGLFS. Everything went just fine, I
> only used another configure options:
> 
> -opengl es2 -optimized-qmake -no-pch -make libs -make tools 
> -reduce-exports -sysroot /home/lukas/raspberry/sysroot -device 
> linux-rasp-pi2-g++ -device-option 
> CROSS_COMPILE=/home/lukas/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-
>  
> -prefix /usr/local/rasp  -opensource -nomake  examples -nomake tests 
> -confirm-license -skip qtmultimedia -skip qtcharts -skip qtsensors
> -skip qtgamepad -skip qtmacextras -skip qtandroidextras -skip
> qtwayland -prefix /usr/local/qt5pi -extprefix /home/lukas/raspi/qt5pi
> -hostprefix /home/lukas/raspi/qt5
> 
> Every qt3d example is compiled just fine, but when I run any of the 
> examples it is not working. Few examples look like everything working 
> just fine (I have also tried to enable logging by no error occurs)
> but nothing is rendered. Few other examples are crashing on fragment
> shader with error message:
> 
> Failed to link shader program: ERROR:OPTIMIZER-3 (fragment shader,
> line 41) Support for for loops is restricted : right side of
> condition expression must be constant
> Segmentation fault
> 
> My settings is:
> - Raspberry Pi 3 using raspbian lite without pixel
> - Host PC is Linux Mint 17.2 64bit
> - I want to use qt3d without X11 or Wayland if possible!
> 
> Output from "ldd simple-qml"
>  linux-vdso.so.1 (0x7eec6000)
>  /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f29000)
>  libQt53DExtras.so.5 => /usr/local/qt5pi/lib/libQt53DExtras.so.5 
> (0x76ec8000)
>  libQt53DQuickExtras.so.5 => 
> /usr/local/qt5pi/lib/libQt53DQuickExtras.so.5 (0x76ec2000)
>  libQt5Concurrent.so.5
> => /usr/local/qt5pi/lib/libQt5Concurrent.so.5 (0x76ebd000)
>  libQt53DRender.so.5 => /usr/local/qt5pi/lib/libQt53DRender.so.5 
> (0x76d12000)
>  libQt53DInput.so.5 => /usr/local/qt5pi/lib/libQt53DInput.so.5 
> (0x76c9e000)
>  libQt53DLogic.so.5 => /usr/local/qt5pi/lib/libQt53DLogic.so.5 
> (0x76c92000)
>  libQt53DQuick.so.5 => /usr/local/qt5pi/lib/libQt53DQuick.so.5 
> (0x76c73000)
>  libQt53DCore.so.5 => /usr/local/qt5pi/lib/libQt53DCore.so.5 
> (0x76c2b000)
>  libQt5Quick.so.5 => /usr/local/qt5pi/lib/libQt5Quick.so.5
> (0x768d5000) libQt5Gui.so.5 => /usr/local/qt5pi/lib/libQt5Gui.so.5
> (0x76463000) libQt5Qml.so.5 => /usr/local/qt5pi/lib/libQt5Qml.so.5
> (0x760f6000) libQt5Network.so.5
> => /usr/local/qt5pi/lib/libQt5Network.so.5 (0x75f95000)
>  libQt5Core.so.5 => /usr/local/qt5pi/lib/libQt5Core.so.5
> (0x75af) libGLESv2.so => /opt/vc/lib/libGLESv2.so (0x75acb000)
>  libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 
> (0x75aa3000)
>  libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 
> (0x759c6000)
>  libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x7594b000)
>  libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1
> (0x7591e000) libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6
> (0x757dd000) libpng12.so.0 => /lib/arm-linux-gnueabihf/libpng12.so.0
> (0x757ac000) libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1
> (0x75785000) librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1
> (0x7576e000) libicui18n.so.52
> => /usr/lib/arm-linux-gnueabihf/libicui18n.so.52 (0x755ae000)
>  libicuuc.so.52 => /usr/lib/arm-linux-gnueabihf/libicuuc.so.52 
> (0x75465000)
>  libicudata.so.52
> => /usr/lib/arm-linux-gnueabihf/libicudata.so.52 (0x73de7000)
>  libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x73dd4000)
>  libgthread-2.0.so.0 => 
> /usr/lib/arm-linux-gnueabihf/libgthread-2.0.so.0 (0x73dc2000)
>  libglib-2.0.so.0 => /lib/arm-linux-gnueabihf/libglib-2.0.so.0 
> (0x73cbf000)
>  /lib/ld-linux-armhf.so.3 (0x54b6f000)
>  libEGL.so => /opt/vc/lib/libEGL.so (0x73c86000)
>  libbcm_host.so => /opt/vc/lib/libbcm_host.so (0x73c5f000)
>  libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0x73c49000)
>  libvcos.so => /opt/vc/lib/libvcos.so (0x73c2f000)
>  libpcre.so.3 => /lib/arm-linux-gnueabihf/libpcre.so.3
> (0x73bbc000)
> 
> Do I miss something? I have already tried same steps on Raspberry
> PiB+ but the result was just same.
> 
> Thanks for any answer.
> 

It's a fault/limitation in the Pi graphics driver - non-constant RHS in
a for-loop condition is valid GLSL, but the driver fails to support it
anyway.
Try using the open-source `vc4` driver (part of Mesa) instead of the
mostly-closed one that's currently standard; it has better GLSL support.

-Francis
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-proje

[Interest] QML Canvas - imagedata and context setup

2015-09-19 Thread Francis Herne
For a couple of days now, I've been trying to use QML Canvas in my application.

Initially I ran into 'bugs' with tiling mode (not only is it completely broken 
for any usage, according to a dev on IRC it always has been - yet it's 
recommended for some purposes in the docs). http://i.imgur.com/MqfzSoM.png


Having given up on that, I can't find a way to reliably create and use 
CanvasImageData objects. The image URL has to be 'loaded' first with 
Canvas::loadImage(), then the object actually created with 
Context2D::createImageData().

My first problem is that Canvas::loadImage() is asynchronous, so for an unknown 
time after calling it it's not possible to create the data object. The docs 
suggest using the onImageLoaded handler for that, but:

 - It doesn't specify _which_ image was loaded, so I have to try to check every 
image that I might have been trying to load. Annoying but minor.

 - There's no guarantee that the Canvas is even available when the signal is 
emitted. So I get "QML NewCanvas: Unable to use getContext() at this time, 
please wait for available: true", or a null context. Looping for the context to 
become available just causes a hang. Not trying to create the image object 
obviously leaves said object uncreated.

Even when that happens to work, I just get more trouble:

 - There's also no guarantee that the context can be obtained before PAINT 
EVENTS are received. This seems utterly ridiculous to me - the sole example 
code for Context2D in the docs reads:
"
onPaint:{
 var ctx = canvas.getContext('2d');
 //...
}
"
yet this will actually fail a noticeable proportion of the time. As before, 
looping just causes a hang. There's no return status from onPaint, so being 
unable to draw anything results in blank bits of canvas.

 - Same for image loading - images might not have finished loading, so 
drawImage() has nothing to draw. I can't find a way to wait for this either.



Can anyone advise how I can use this API without all the race conditions?
So far I haven't even managed "load an image and draw it in the corner of the 
canvas", so an example for that would be really useful.

Thanks in advance for any suggestions,
Francis Herne

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest