[Interest] Qt API annoyances: where to log/discuss?

Jason H jhihn at gmx.com
Wed Oct 31 18:35:15 CET 2018



> Sent: Tuesday, October 30, 2018 at 3:23 PM
> From: "Thiago Macieira" <thiago.macieira at intel.com>
> To: interest at qt-project.org
> Subject: Re: [Interest] Qt API annoyances: where to log/discuss?
>
> On Tuesday, 30 October 2018 08:39:22 PDT Jason H wrote:
> > I was wondering if there is a place to log annoyances/discuss with the Qt5
> > API for fix in Qt6?
> 
> This list or the development mailing list are fine.
> 
> > 
> > Two I am thinking of right now is:
> > - QUrl::port() returns an int, but QTcpServer accepts a quint16, so no
> > matter what I do, unless I add a cast, I get a warning. 
> 
> That's because QUrl::port() can return -1, indicating "no port was set in the 
> URL". QTcpServer needs a valid port number. So the warning is correct and 
> should be acted on.

I thought QUrl::port() can take a default port if not set. Does it need to be able to return negative?

> > - Similarly with
> > QImage::pixel there are signed/unsigned issues between pixel and qRgb().
> 
> Sounds like something to be fixed.
> 
> > Also, as I go between several languages, I find myself wanting to use
> > lambdas more in a functional programming style. ( I would like a lambda for
> > QImage::pixel ([] (x,y,pixelValue) { } ) (This one is neat because you can
> > use scanline() transparently) Also for the various containers.
> 
> Highly inefficient, so unlikely to happen.

In my own testing it was not that inefficient. In fact the lambda using scanLine() was faster than using pixel(), but yes slower than using scanLine with for loops. 

> 
> As for the containers, use <algorithm> and C++2a Ranges.

I attempted this recently, but failed to figure out how to do the following:
QVector<int> triple = apply(QVector<int> {1,2,3},[](item) { return item*3;});
or 
QVector<int> originals {1,2,3};
QVector<int> triples = originals.apply([](item) { return item*3;});

My options are std::for_each, std::transform, but they all have an ugly, over-complicated syntax.

Compare that to:
 std::vector<int> originals { 1,2,3};
 std::vector<int> triples;
 std::transform(originals.begin(), originals.end(), std::back_inserter(triples), [](int item){ return item*3; });

Sure the std way works 100% of the time, but I don't want to read that code, much less write it. I think there's something about how "friendly" and "beautiful" Qt code looks. 


 





More information about the Interest mailing list