[Qt-interest] Weird compiler error with QString(QChar(value))
Stephen Chu
stephen at ju-ju.com
Thu May 6 17:37:25 CEST 2010
In article <hrul12$9l1$1 at eple.troll.no>,
Nikos Chantziaras <realnc at arcor.de> wrote:
> On 05/06/2010 05:35 PM, Stephen Chu wrote:
> > In article<201005052127.23761.thiago at kde.org>,
> > Thiago Macieira<thiago at kde.org> wrote:
> >
> > Thanks for the explanation. I ran into the same problem just last night.
> > Pulling my hairs out on this one.
> >
> > One question though. If that line of code actually declares a function,
> > what does 'unicodeValue' in the declaration do? I thought a function
> > declaration is something like:
> >
> > QString s(QChar unicodeValue);
>
> It's the same since you can put parentheses pretty much everywhere. As
> I posted previously for example, you can define main() like this:
>
> int main( int(argc), char**(argv) )
>
> and it's accepted by the compiler. That means that these two function
> declarations:
>
> QString s(QChar unicodeValue);
> QString s(QChar(unicodeValue));
>
> are equivalent. IMHO that's wrong, but then again, I don't know what
> would break in the C++ standard if it would treat it as wrong. But
> given that C++ allows you to use simple types (int, char, etc) as classes:
>
> int i = int(50); //'int' is not a class, but you can use it as one
>
> it should bark at the above definition of main().
Got it. Thanks. I was pulling my hairs when something like:
QRectF r(QRectF(aPixmap.rect()));
works but this doesn't:
QRectF r(QRectF(aRect));
Learn another trick (or trap?). The compiler should at least put a more
informative warning on that line.
--
Stephen Chu
More information about the Qt-interest-old
mailing list