Re: [Interest] QFutureWatcher not emitting signals

2016-11-23 Thread Bob Hood
Nevermind.  It's a problem at the macro level.  This will only work when the 
Tasklet class is created from the main thread.  I was creating it from deep 
down inside calls originating from a QThread object, which is apparently a no-no.


I'll refactor to notify the main thread to create these instances, and all 
should be well.


Sorry to bother.


On 11/23/2016 8:16 PM, Bob Hood wrote:
I did some Googling about this, and found a LOT of hits about QFutureWatcher 
not emitting its signals (like finished()) when the QFuture it's watching 
completes.  However, in all cases I've seen, people were using an auto 
version of QFutureWatcher which dropped out of scope on them (i.e., 
allocated on the local stack). Allocating it on the heap seemed to solve all 
problems I found.


Well, it isn't solving it for me.  I'm using Qt 5.6.2.  I have a simple 
tasklet class that performs a discrete function in a separate thread 
independent of the main process.  Its basic structure looks like this:


Definition:

class Tasklet : public QObject
{
Q_OBJECT
public:
Tasklet(...args...);
~Tasklet();

signals:
voidsignal_result(const QString& reference, bool result);

private slots:
voidslot_future_finished();

private:// methods
boolrun();

private:// data members
...args...

QFutureWatcher*   watcher;
};

Implementation:

Tasklet::Tasklet(...args...) : ...init...
{
QFuture future = QtConcurrent::run(this, ::run);
watcher = new QFutureWatcher();
connect(watcher, ::finished, this, 
::slot_future_finished);

watcher->setFuture(future);
}

bool Tasklet::run()
{
...processing...
return true;
}

void Tasklet::slot_future_finished()
{
emit signal_result(reference, watcher->result());
watcher->deleteLater();
}

Tasklet::slot_future_finished() is NEVER called. I've verified that the 
connect() returns true, tried using the old-style syntax for connect, and 
I've also tried having a class member for QFutureWatcher instead of 
allocating it on the heap. No joy.


Can another pair of eyes see what am I doing wrong here?
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest



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


[Interest] QFutureWatcher not emitting signals

2016-11-23 Thread Bob Hood
I did some Googling about this, and found a LOT of hits about QFutureWatcher 
not emitting its signals (like finished()) when the QFuture it's watching 
completes.  However, in all cases I've seen, people were using an auto version 
of QFutureWatcher which dropped out of scope on them (i.e., allocated on the 
local stack). Allocating it on the heap seemed to solve all problems I found.


Well, it isn't solving it for me.  I'm using Qt 5.6.2.  I have a simple 
tasklet class that performs a discrete function in a separate thread 
independent of the main process.  Its basic structure looks like this:


Definition:

class Tasklet : public QObject
{
Q_OBJECT
public:
Tasklet(...args...);
~Tasklet();

signals:
voidsignal_result(const QString& reference, bool result);

private slots:
voidslot_future_finished();

private:// methods
boolrun();

private:// data members
...args...

QFutureWatcher*   watcher;
};

Implementation:

Tasklet::Tasklet(...args...) : ...init...
{
QFuture future = QtConcurrent::run(this, ::run);
watcher = new QFutureWatcher();
connect(watcher, ::finished, this, 
::slot_future_finished);

watcher->setFuture(future);
}

bool Tasklet::run()
{
...processing...
return true;
}

void Tasklet::slot_future_finished()
{
emit signal_result(reference, watcher->result());
watcher->deleteLater();
}

Tasklet::slot_future_finished() is NEVER called. I've verified that the 
connect() returns true, tried using the old-style syntax for connect, and I've 
also tried having a class member for QFutureWatcher instead of allocating it 
on the heap. No joy.


Can another pair of eyes see what am I doing wrong here?
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] [QGView] Center align text item that ignores inherited transformation

2016-11-23 Thread Ch'Gans
On 24 November 2016 at 01:43, Majid Kamali  wrote:
> Hi. Check this code:
>
> void centerItemInRect(QGraphicsItem *item, QRectF rect)
> {
> float x = rect.width() -
> item->boundingRegion(item->transform()).boundingRect().width();
> x /= 2;
> float y = rect.height() -
> item->boundingRegion(item->transform()).boundingRect().height();
> y /= 2;
>
> item->setPos(x + rect.x(), y + rect.y());
> }
>
> This code works if you use Transformation on QGItem. It does not work if you
> set scale and rotation with setRotation and setScale.

Thanks for sharing, but this does not work when the item has the
ItemIgnoresTransformation flag set.

I think it's simply not possible to center-align a QGSimpleTextItem
without writing a custom QGItem wrapper of re-writing a simple text
item from scratch...
The main problem is that the bounding region/rect of the item is
expressed in device coordinates (pixels), and the item transform is
relative to parent (or scene) coordinates, so you cannot mix both.

Chris


>
>
> On Wed, Nov 23, 2016 at 4:15 AM, Ch'Gans  wrote:
>>
>> Hi there,
>>
>> I'm trying to add a QGraphicsSimpleTextItem as a child of another (shape)
>> item.
>> I want the text to not follow scaling of the view (I use
>> QGraphicsItem::ItemIgnoreTransformations flag), *and* be always
>> centered on it's parent shape.
>> Ideally, i'm looking at a solution that doesn't require to create a
>> custom QGItem.
>>
>> My problem is the centering of the text item itself, without
>> centering, here is what i do:
>>
>> --
>> auto item = new ...
>> ...
>> auto text = new QGraphicsSimpleTextItem(item);
>> text->setText(...);
>> text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
>> auto itemCenter = QPointF(item->boundingRect().width()/2.0,
>>
>> item->boundingRect().height()/2.0);
>> text->setPos(itemCenter);
>>
>> --
>>
>> This work fine, but (as expected) the top-left of the text is
>> positioned on the center of the parent item.
>> To center-align, I tried:
>>
>> ---
>> auto textCenter = QPointF(text->boundingRect().width()/2.0,
>>
>> text->boundingRect().height()/2.0);
>> text->setTransform(QTransform::fromTranslate(-textCenter.x, -textCenter));
>>
>> ---
>>
>> But this doesn't work because textCenter is an offset in a coordinate
>> system that doesn't follow view scaling... and the text transform
>> seems to be applied in the "scaled space".
>>
>> Basically my problem is that it seems that I need a dynamic
>> positioning wrt the parent that depends on the view transform...
>>
>> Does anyone know some tricks on how to achieve this?
>>
>> Thanks,
>> Chris
>> ___
>> Interest mailing list
>> Interest@qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>
>
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] camera APIs -- intended usage

2016-11-23 Thread Tyler Daniel
Hello and thanks for the follow up!

Yes, I am processing live video in c++.  I’m implementing a custom qml 
component to display the results.  Other than that, I don’t see why qml needs 
to be involved.  I only need to turn on the camera, get preview-sized images, 
and tell it to capture full resolution stills.

This is pretty much the most basic thing you can do with a camera.  Honestly 
it’s disappointing that even after years of claiming to support mobile it’s 
still difficult to do something so simple.

QVideoProbe — as I mentioned I got this to work on Android a while ago but not 
on iOS.  I get the impression that it is a hack to deal with Android’s java/c++ 
split  personality.

Tyler

> On 2016/11/23, at 23:20, Jason H  wrote:
> 
> I'm being ambiguous because it's been some time since I work with that part 
> of Qt, and I don't want to tell you something that's not true.
>  
> The QML camera capture api provides athe url of a preview image which is a 
> URL (imageProviderUrl) - you'll need to use a ImageProvider to get the data.
> 
> QQmlEngine *engine = QQmlEngine::contextForObject(this)->engine();
> QQmlImageProviderBase *imageProviderBase = 
> engine->imageProvider(imageProviderUrl.host());
> QQuickImageProvider *imageProvider = 
> static_cast(imageProviderBase);
> QSize imageSize;
> QString imageId = imageProviderUrl.path().remove(0,1);
> QImage image = imageProvider->requestImage(imageId, , imageSize);
>  
> However if you are looking to process live video frames and not 1-offs, 
> you'll need to use QVideoProbe, but QVideoProbe would crash the app after 
> some time. *Somewhere* I *might* have code. However, since I wrote that code, 
> QVideoFilter is now a thing: 
> http://blog.qt.io/blog/2015/03/20/introducing-video-filters-in-qt-multimedia/
>  
> I am sorry I can't give you definites, but I hope that helps in some way.
>  
>  
> Sent: Wednesday, November 23, 2016 at 7:51 AM
> From: "Tyler Daniel" 
> To: "Jason H" 
> Cc: interest@qt-project.org
> Subject: Re: [Interest] camera APIs -- intended usage
> Hi, thanks very much for the response!
>  
> I understand that you generally want the viewfinder to related to the screen 
> size and I suppose this is why there’s a separate viewfinder api.  I’ve also 
> written native iOS camera apps before and have some familiarity with 
> AVFoundation.
>  
> Unfortunately my questions stand:
>  
> 1) how do I get viewfinder frames (live preview frames) at resolution X and 
> still images at resolution Y, where Y is the maximum resolution and X is 
> lower.  
>  
> 2) why does the setViewfinderSettings() and setEncodingSettings() example 
> below behave the way it does?  is this a bug, or intended behavior?
>  
> Tyler
>  
>  
>  
> On 2016/11/23, at 3:29, Jason H > wrote:
>  
> The viewfinder corresponds to the screen size, the full-capture corresponds 
> to the CCD, or what you have the CCD configured to capture. The AVFoundation 
> API on iOS has support for capturing frames and resizing them to requested 
> sizes for various consumers. You're probably seeing something related to 
> that. It's probably giving you the highest resolution requested.
>  
> When I capture the "preview" image in QML, it is sized accordingly. 
>  
> Sent: Monday, November 21, 2016 at 8:29 PM
> From: "Tyler Daniel"  >
> To: interest@qt-project.org 
> Subject: [Interest] camera APIs -- intended usage
> Hi all, I recently posted this in the forums, where it was suggested that I 
> ask my questions here.  Sorry if this is a duplicate for someone.
>  
> I'm building an iOS camera app and need the viewfinder/preview frames in 
> c++-land. I also need full-resolution still images when a capture button is 
> pressed.
> 
> I can subclass QAbstractSurface and use QCamera::setViewfinder() to get 
> frames. The problem is that the frames I get for the preview are the same 
> resolution as the still images. I'm testing on an iPhone 5, so I either get 
> 3264 or 1920, let's say 3k or 2k.
> 
> I'm using QCamera and QCameraImageCapture in c++ code.
> 
> If I use QCameraImageCapture::setEncodingSettings with 3k and 
> QCamera::setViewfinderSettings with 2k, I get 3k preview frames and 3k still 
> images.
> 
> I would have thought that the viewfinder api affects the viewfinder 
> resolution and the camera image capture affects a separate still image 
> capture resolution. But this is not the behavior I'm seeing.
> 
> Each of these classes are documented in the doxygen sense, but intended usage 
> and how they work together is not.  The closest I can find is the detailed 
> description of QCameraImageCapture, which provides a nice code snippet, but… 
> resolution problems.
> 
> Pretty much all smartphones and digital cameras show a lower-resolution 
> preview and capture stills at a 

Re: [Interest] camera APIs -- intended usage

2016-11-23 Thread Jason H

I'm being ambiguous because it's been some time since I work with that part of Qt, and I don't want to tell you something that's not true.

 

The QML camera capture api provides athe url of a preview image which is a URL (imageProviderUrl) - you'll need to use a ImageProvider to get the data.


QQmlEngine *engine = QQmlEngine::contextForObject(this)->engine();
QQmlImageProviderBase *imageProviderBase = engine->imageProvider(imageProviderUrl.host());
QQuickImageProvider *imageProvider = static_cast(imageProviderBase);
QSize imageSize;
QString imageId = imageProviderUrl.path().remove(0,1);
QImage image = imageProvider->requestImage(imageId, , imageSize);

 

However if you are looking to process live video frames and not 1-offs, you'll need to use QVideoProbe, but QVideoProbe would crash the app after some time. *Somewhere* I *might* have code. However, since I wrote that code, QVideoFilter is now a thing: http://blog.qt.io/blog/2015/03/20/introducing-video-filters-in-qt-multimedia/

 

I am sorry I can't give you definites, but I hope that helps in some way.

 

 

Sent: Wednesday, November 23, 2016 at 7:51 AM
From: "Tyler Daniel" 
To: "Jason H" 
Cc: interest@qt-project.org
Subject: Re: [Interest] camera APIs -- intended usage



Hi, thanks very much for the response!

 

I understand that you generally want the viewfinder to related to the screen size and I suppose this is why there’s a separate viewfinder api.  I’ve also written native iOS camera apps before and have some familiarity with AVFoundation.

 

Unfortunately my questions stand:

 

1) how do I get viewfinder frames (live preview frames) at resolution X and still images at resolution Y, where Y is the maximum resolution and X is lower.  

 

2) why does the setViewfinderSettings() and setEncodingSettings() example below behave the way it does?  is this a bug, or intended behavior?

 

Tyler

 

 
 



On 2016/11/23, at 3:29, Jason H  wrote:
 





The viewfinder corresponds to the screen size, the full-capture corresponds to the CCD, or what you have the CCD configured to capture. The AVFoundation API on iOS has support for capturing frames and resizing them to requested sizes for various consumers. You're probably seeing something related to that. It's probably giving you the highest resolution requested.

 

When I capture the "preview" image in QML, it is sized accordingly. 

 

Sent: Monday, November 21, 2016 at 8:29 PM
From: "Tyler Daniel" 
To: interest@qt-project.org
Subject: [Interest] camera APIs -- intended usage


Hi all, I recently posted this in the forums, where it was suggested that I ask my questions here.  Sorry if this is a duplicate for someone.
 


I'm building an iOS camera app and need the viewfinder/preview frames in c++-land. I also need full-resolution still images when a capture button is pressed.

I can subclass QAbstractSurface and use QCamera::setViewfinder() to get frames. The problem is that the frames I get for the preview are the same resolution as the still images. I'm testing on an iPhone 5, so I either get 3264 or 1920, let's say 3k or 2k.

I'm using QCamera and QCameraImageCapture in c++ code.

If I use QCameraImageCapture::setEncodingSettings with 3k and QCamera::setViewfinderSettings with 2k, I get 3k preview frames and 3k still images.

I would have thought that the viewfinder api affects the viewfinder resolution and the camera image capture affects a separate still image capture resolution. But this is not the behavior I'm seeing.

Each of these classes are documented in the doxygen sense, but intended usage and how they work together is not.  The closest I can find is the detailed description of QCameraImageCapture, which provides a nice code snippet, but… resolution problems.

Pretty much all smartphones and digital cameras show a lower-resolution preview and capture stills at a higher resolution.

My question is how to achieve this with iOS? What should work? How do I get 2k preview frames in c++ and 3k still captures?

I’ve looked at the example apps.  They work on iOS in the sense that they don't crash, but they exhibit the same behavior with previews and stills at the same resolution. 

I’m currently working with 5.7 and 5.8 beta, but honestly I’ve had problems with the camera apis for years now.  On Android I hacked something that worked with QVideoProbe, but only for Android.  On iOS I gave up and went native.  Never found a solution that worked for more than one platform.

 

Any help would be most appreciated!

 

Tyler

 

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














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


Re: [Interest] QGamepad on Mac OS X

2016-11-23 Thread Andy
Maybe I'll try a more general question: Has anyone been successful at
getting an xbox controller to work on any version of Mac OS X with any
version of Qt?

Thank you for your time.

---
Andy Maloney  //  https://asmaloney.com
twitter ~ @asmaloney 


On Sun, Nov 20, 2016 at 12:04 PM, Andy  wrote:

> I'm trying to get an xbox controller working on Mac OS X 10.10.5 with the
> QGamepadManager and the latest 5.8 git.
>
> First I need a driver, so I got this one:
>
>   https://github.com/360Controller/360Controller/releases
>
> Seems to work - the control panel recognizes the controller and responds
> to input.
>
> QGamepadManager doesn't recognize it though.  connectedGamepads() returns
> an empty list.
>
> I would expect that if the driver is properly installed, and the device is
> plugged in, then QGamepadManager would recognize it.
>
> What am I missing?
>
> Thanks!
>
> ---
> Andy Maloney  //  https://asmaloney.com
> twitter ~ @asmaloney 
>
>
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] camera APIs -- intended usage

2016-11-23 Thread Tyler Daniel
Hi, thanks very much for the response!

I understand that you generally want the viewfinder to related to the screen 
size and I suppose this is why there’s a separate viewfinder api.  I’ve also 
written native iOS camera apps before and have some familiarity with 
AVFoundation.

Unfortunately my questions stand:

1) how do I get viewfinder frames (live preview frames) at resolution X and 
still images at resolution Y, where Y is the maximum resolution and X is lower. 
 

2) why does the setViewfinderSettings() and setEncodingSettings() example below 
behave the way it does?  is this a bug, or intended behavior?

Tyler



> On 2016/11/23, at 3:29, Jason H  wrote:
> 
> The viewfinder corresponds to the screen size, the full-capture corresponds 
> to the CCD, or what you have the CCD configured to capture. The AVFoundation 
> API on iOS has support for capturing frames and resizing them to requested 
> sizes for various consumers. You're probably seeing something related to 
> that. It's probably giving you the highest resolution requested.
>  
> When I capture the "preview" image in QML, it is sized accordingly. 
>  
> Sent: Monday, November 21, 2016 at 8:29 PM
> From: "Tyler Daniel" 
> To: interest@qt-project.org
> Subject: [Interest] camera APIs -- intended usage
> Hi all, I recently posted this in the forums, where it was suggested that I 
> ask my questions here.  Sorry if this is a duplicate for someone.
>  
> I'm building an iOS camera app and need the viewfinder/preview frames in 
> c++-land. I also need full-resolution still images when a capture button is 
> pressed.
> 
> I can subclass QAbstractSurface and use QCamera::setViewfinder() to get 
> frames. The problem is that the frames I get for the preview are the same 
> resolution as the still images. I'm testing on an iPhone 5, so I either get 
> 3264 or 1920, let's say 3k or 2k.
> 
> I'm using QCamera and QCameraImageCapture in c++ code.
> 
> If I use QCameraImageCapture::setEncodingSettings with 3k and 
> QCamera::setViewfinderSettings with 2k, I get 3k preview frames and 3k still 
> images.
> 
> I would have thought that the viewfinder api affects the viewfinder 
> resolution and the camera image capture affects a separate still image 
> capture resolution. But this is not the behavior I'm seeing.
> 
> Each of these classes are documented in the doxygen sense, but intended usage 
> and how they work together is not.  The closest I can find is the detailed 
> description of QCameraImageCapture, which provides a nice code snippet, but… 
> resolution problems.
> 
> Pretty much all smartphones and digital cameras show a lower-resolution 
> preview and capture stills at a higher resolution.
> 
> My question is how to achieve this with iOS? What should work? How do I get 
> 2k preview frames in c++ and 3k still captures?
> 
> I’ve looked at the example apps.  They work on iOS in the sense that they 
> don't crash, but they exhibit the same behavior with previews and stills at 
> the same resolution. 
> 
> I’m currently working with 5.7 and 5.8 beta, but honestly I’ve had problems 
> with the camera apis for years now.  On Android I hacked something that 
> worked with QVideoProbe, but only for Android.  On iOS I gave up and went 
> native.  Never found a solution that worked for more than one platform.
> 
>  
> Any help would be most appreciated!
>  
> Tyler
>  
> ___ Interest mailing list 
> Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest 
> 
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] [QGView] Center align text item that ignores inherited transformation

2016-11-23 Thread Majid Kamali
Hi. Check this code:

void centerItemInRect(QGraphicsItem *item, QRectF rect)
{
float x = rect.width() -
item->boundingRegion(item->transform()).boundingRect().width();
x /= 2;
float y = rect.height() -
item->boundingRegion(item->transform()).boundingRect().height();
y /= 2;

item->setPos(x + rect.x(), y + rect.y());
}

This code works if you use Transformation on QGItem. It does not work if
you set scale and rotation with setRotation and setScale.


On Wed, Nov 23, 2016 at 4:15 AM, Ch'Gans  wrote:

> Hi there,
>
> I'm trying to add a QGraphicsSimpleTextItem as a child of another (shape)
> item.
> I want the text to not follow scaling of the view (I use
> QGraphicsItem::ItemIgnoreTransformations flag), *and* be always
> centered on it's parent shape.
> Ideally, i'm looking at a solution that doesn't require to create a
> custom QGItem.
>
> My problem is the centering of the text item itself, without
> centering, here is what i do:
> 
> --
> auto item = new ...
> ...
> auto text = new QGraphicsSimpleTextItem(item);
> text->setText(...);
> text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
> auto itemCenter = QPointF(item->boundingRect().width()/2.0,
> item->boundingRect().height()/
> 2.0);
> text->setPos(itemCenter);
> 
> --
>
> This work fine, but (as expected) the top-left of the text is
> positioned on the center of the parent item.
> To center-align, I tried:
> 
> ---
> auto textCenter = QPointF(text->boundingRect().width()/2.0,
>text->boundingRect().height()/
> 2.0);
> text->setTransform(QTransform::fromTranslate(-textCenter.x, -textCenter));
> 
> ---
>
> But this doesn't work because textCenter is an offset in a coordinate
> system that doesn't follow view scaling... and the text transform
> seems to be applied in the "scaled space".
>
> Basically my problem is that it seems that I need a dynamic
> positioning wrt the parent that depends on the view transform...
>
> Does anyone know some tricks on how to achieve this?
>
> Thanks,
> Chris
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] Open source license attribution when deploying a Qt-based application

2016-11-23 Thread Ola Røer Thorsen
I plan to release a closed source Qt-based application in a few months.
It's using the LGPL version of Qt, and I plan to bundle the Qt dynamic
libraries and plugins I need along with the application in an installer.

I have built up a list of the open source libraries that I have used along
with their license text available from inside the application (help - about
etc). Here Qt itself is included. Should I also add all the libraries that
Qt have used here? That means practically more or less this whole list:
http://doc.qt.io/qt-5/3rdparty.html ?

Any hints to what is the commonly accepted practice would be welcome.

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