Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, May 2007
What’s wrong with Qt4.3.0beta compiler?


Message 1 in thread

My codes work well in Qt4.1.1, but fail to compile in 4.3.0beta. Errors 
are copied below:

c:\myQt\_gui\XbelTree.h(14) : error C2440: 'initializing' : cannot 
convert from 'void' to 'int'
        Expressions of type void cannot be converted to other types
        
c:\Qt\4.3.0beta\include\QtCore\../../src\corelib\kernel\qobject.h(409) : 
see reference to function template instantiation 'void 
XbelTree::qt_check_for_QOBJECT_macro<TreeParser>(const T &) const' being 
compiled
        with
        [
            T=TreeParser
        ]
        MainWindow.cc(152) : see reference to function template 
instantiation 'T qobject_cast<TreeParser*>(QObject *)' being compiled
        with
        [
            T=TreeParser *
        ]

What’s wrong with Qt4.3.0beta compiler?
Which version is the last safe version?

Thanks,
Lingfa

--
 [ signature omitted ] 

Message 2 in thread

Hi,

> My codes work well in Qt4.1.1, but fail to compile in 4.3.0beta. Errors 
> are copied below:
> 
> c:\myQt\_gui\XbelTree.h(14) : error C2440: 'initializing' : cannot 
> convert from 'void' to 'int'
>        Expressions of type void cannot be converted to other types

That looks like an error in your code, although it's true that the error 
message isn't clear. From file src/corelib/kernel/qobjectdefs.h in Qt 4.3:

/* This is a compile time check that ensures that any class casted with
    qobject_cast actually contains a Q_OBJECT macro. Note: qobject_cast
    will fail if a QObject subclass doesn't contain Q_OBJECT.

    In qt_check_for_QOBJECT_macro, we call a dummy templated function with two
    parameters, the first being "this" and the other the target of the qobject
    cast. If the types are not identical, we know that a Q_OBJECT macro is
    missing.

    If you get a compiler error here, make sure that the class you are casting
    to contains a Q_OBJECT macro.
*/

--
 [ signature omitted ] 

Message 3 in thread

Dimitri wrote:

> Hi,
>
>> My codes work well in Qt4.1.1, but fail to compile in 4.3.0beta. 
>> Errors are copied below:
>>
>> c:\myQt\_gui\XbelTree.h(14) : error C2440: 'initializing' : cannot 
>> convert from 'void' to 'int'
>>        Expressions of type void cannot be converted to other types
>
>
> That looks like an error in your code, although it's true that the 
> error message isn't clear. From file src/corelib/kernel/qobjectdefs.h 
> in Qt 4.3:

But why my code passes 4.1.1 if there is an error. Also, I just 
installed Qt4.2.3 and tested it in Qt4.2.3, it's fine.
So I am happy to stay with 4.2.3, NOT rush on the immature 4.3.0beta.
Thank you anyway.
Lingfa


--
 [ signature omitted ] 

Message 4 in thread

On 03.05.07 16:34:12, Lingfa Yang wrote:
> Dimitri wrote:
> >>My codes work well in Qt4.1.1, but fail to compile in 4.3.0beta. Errors are 
> >>copied below:
> >>
> >>c:\myQt\_gui\XbelTree.h(14) : error C2440: 'initializing' : cannot convert 
> >>from 'void' to 'int'
> >>       Expressions of type void cannot be converted to other types
> >
> >
> >That looks like an error in your code, although it's true that the error 
> >message isn't clear. From file src/corelib/kernel/qobjectdefs.h in Qt 4.3:
> 
> But why my code passes 4.1.1 if there is an error. Also, I just installed 
> Qt4.2.3 and tested it in Qt4.2.3, it's fine.

So you mean the class that you use in the qobject_cast does have the
QOBJECT macro in its header?

> So I am happy to stay with 4.2.3, NOT rush on the immature 4.3.0beta.

Uhm, well. 4.3.0beta isn't that immature, although its not of release
quality yet.

Andreas

-- 
 [ signature omitted ] 

Message 5 in thread

Hi,

> But why my code passes 4.1.1 if there is an error. Also, I just 
> installed Qt4.2.3 and tested it in Qt4.2.3, it's fine.
> So I am happy to stay with 4.2.3, NOT rush on the immature 4.3.0beta.
> Thank you anyway.

What I meant to say is that this is probably an error in your code, that is 
caught by Qt 4.3 but was not caught by Qt 4.2 and earlier. If I'm correct, 
this has nothing to do with Qt 4.3 being immature. Of course you're free to 
ignore warnings.
Good luck ;-)

--
 [ signature omitted ] 

Message 6 in thread

Dimitri wrote:

> Hi,
>
>> But why my code passes 4.1.1 if there is an error. Also, I just 
>> installed Qt4.2.3 and tested it in Qt4.2.3, it's fine.
>> So I am happy to stay with 4.2.3, NOT rush on the immature 4.3.0beta.
>> Thank you anyway.
>
>
> What I meant to say is that this is probably an error in your code, 
> that is caught by Qt 4.3 but was not caught by Qt 4.2 and earlier. If 
> I'm correct, this has nothing to do with Qt 4.3 being immature. Of 
> course you're free to ignore warnings.
> Good luck ;-)
>

I just finished “Clean Solution” and then “Build Solution” in Qt4.2.3 
with Warning Level 3 (/W3)
The only warning I obtained is:
“powerpoint.cpp(66208) : warning C4049: compiler limit : terminating 
line number emission
        Compiler limit for line number is 65535
”
Obviously this is not related with the error reported by 4.3.0beta.
Lingfa


--
 [ signature omitted ] 

Message 7 in thread

 
> I just finished "Clean Solution" and then "Build Solution" in Qt4.2.3
> with Warning Level 3 (/W3)
> The only warning I obtained is:
> Obviously this is not related with the error reported by 4.3.0beta.
> Lingfa

Thats like saying "if i turn off compiler warnings, my code compiles
fine. so the warnings are the problem, not my code".

Qt 4.3.0beta introduces new compile time checks. sorry if this is
annoying, but it's probably pointing you to problem areas in your code.

Cheers,
Peter

--
 [ signature omitted ] 

Message 8 in thread

Peter Prade wrote:

> 
>  
>
>>I just finished "Clean Solution" and then "Build Solution" in Qt4.2.3
>>with Warning Level 3 (/W3)
>>The only warning I obtained is:
>>Obviously this is not related with the error reported by 4.3.0beta.
>>Lingfa
>>    
>>
>
>Thats like saying "if i turn off compiler warnings, my code compiles
>fine. so the warnings are the problem, not my code".
>  
>
I said "with Warning Level 3" I got one unrelated warning (see last email).
What are you talking about? First, I do not "turn off compiler warnings" 
as you said.
Second, my code compiles NOT fine, because I cannot pass 4.3.0beta 
compiler, and I'm trying to work out.
Finally, I never mentioned "the warnings are the problem, not my code”.
I expect a constructive way to help each other though discussion.
Lingfa

--
 [ signature omitted ] 

Message 9 in thread

On 04.05.07 12:02:47, Lingfa Yang wrote:
> Peter Prade wrote:
> >>I just finished "Clean Solution" and then "Build Solution" in Qt4.2.3
> >>with Warning Level 3 (/W3)
> >>The only warning I obtained is:
> >>Obviously this is not related with the error reported by 4.3.0beta.
> >>Lingfa
> >>   
> >
> >Thats like saying "if i turn off compiler warnings, my code compiles
> >fine. so the warnings are the problem, not my code".
> > 
> I said "with Warning Level 3" I got one unrelated warning (see last email).
> What are you talking about? First, I do not "turn off compiler warnings" as you 
> said.

Well, you said you reverted to an older less-restrictive Qt version
because you've got errors with the new one. Thats not the same, but
similar.

> Second, my code compiles NOT fine, because I cannot pass 4.3.0beta compiler, 
> and I'm trying to work out.
> Finally, I never mentioned "the warnings are the problem, not my codeâ.

I don't have a quote at hand, but your emails always sounded like "Qt4.3
has a bug here because my code doesn't compile anymore", your "qt4.3 is
immature" attiude doesn't help that.

> I expect a constructive way to help each other though discussion.

Well, until now all you showed us is that the class that the
compile-time check complains about is derived from a Qt widget class.
What you didn't show is wether this class and all its parent classes use
the Q_OBJECT macro as first thing in their class declaration. And that
is exactly what the compile time check complains about. So please show
us the class declarations of the 3 involved classes.

Andreas

-- 
 [ signature omitted ] 

Message 10 in thread

Andreas Pakulat wrote:

>On 04.05.07 12:02:47, Lingfa Yang wrote:
>  
>
>>Peter Prade wrote:
>>    
>>
>>>>I just finished "Clean Solution" and then "Build Solution" in Qt4.2.3
>>>>with Warning Level 3 (/W3)
>>>>The only warning I obtained is:
>>>>Obviously this is not related with the error reported by 4.3.0beta.
>>>>Lingfa
>>>>  
>>>>        
>>>>
>>>Thats like saying "if i turn off compiler warnings, my code compiles
>>>fine. so the warnings are the problem, not my code".
>>>
>>>      
>>>
>>I said "with Warning Level 3" I got one unrelated warning (see last email).
>>What are you talking about? First, I do not "turn off compiler warnings" as you 
>>said.
>>    
>>
>
>Well, you said you reverted to an older less-restrictive Qt version
>because you've got errors with the new one. Thats not the same, but
>similar.
>
>  
>
I got errors with the new version, which stopped me. I didnât get âthe 
sameâ or âsimilarâ to which senses.


>>Second, my code compiles NOT fine, because I cannot pass 4.3.0beta compiler, 
>>and I'm trying to work out.
>>Finally, I never mentioned "the warnings are the problem, not my codeâ.
>>    
>>
>
>I don't have a quote at hand, but your emails always sounded like "Qt4.3
>has a bug here because my code doesn't compile anymore", your "qt4.3 is
>immature" attiude doesn't help that.
>
>  
>
The problem are solved, which turns that the new version has strict 
check on qobject_cast.
The class must inherit QObject and be declared with the Q_OBJECT macro 
even though there is no signals/slots.


I took the word âimmatureâ just means âunder developmentâ or ânot 
developed yetâ, or "unfnished".
I get the sense not only from these error check, for example, ActiveQt, 
where I found bugs,
and also the documentation about ActiveQt remains unchanged.

Anyway, if the word makes you unhappy, I apologize for that. I am not 
good at English. I use English for working not for arguing.

>>I expect a constructive way to help each other though discussion.
>>    
>>
>
>Well, until now all you showed us is that the class that the
>compile-time check complains about is derived from a Qt widget class.
>What you didn't show is wether this class and all its parent classes use
>the Q_OBJECT macro as first thing in their class declaration. And that
>is exactly what the compile time check complains about. So please show
>us the class declarations of the 3 involved classes.
>
>Andreas
>
>  
>
I have already posted. Here is a copy from previous emails:
"
class TreeParser : public XbelTree, public MdiAbstract
class XbelTree : public TreeWidget
class TreeWidget : public QTreeWidget, public cNOTIFIER_RECEIVER

TreeParser class does not have Q_OBJECT, and its two first parents 
XbelTree and TreeWidget do have the macro.
"

Again, thanks for helping me solve the problem.
Lingfa


--
 [ signature omitted ] 

Message 11 in thread

Lingfa Yang wrote:
> Andreas Pakulat wrote:
>
>> On 04.05.07 12:02:47, Lingfa Yang wrote:
>>  
>>
>> Well, you said you reverted to an older less-restrictive Qt version
>> because you've got errors with the new one. Thats not the same, but
>> similar.
>>
>>  
>>
> I got errors with the new version, which stopped me. I didnât get âthe 
> sameâ or âsimilarâ to which senses.
>
>
> The problem are solved, which turns that the new version has strict 
> check on qobject_cast.
> The class must inherit QObject and be declared with the Q_OBJECT macro 
> even though there is no signals/slots.
>
Q_OBJECT is required for signals and slots. However, other Qt features 
also requires Q_OBJECT like, properties, plugins and qobject_cast.  In 
fact the docs for 4.2.3 (and probably most previous versions) state in 
the qobject_cast doc page:

The qobject_cast() function behaves similarly to the standard C++ 
dynamic_cast(), with the advantages that it doesn't require RTTI support 
and it works across dynamic library boundaries.
Warning: If T isn't declared with the Q_OBJECT macro, this function's 
return value is undefined.

I think this new compile time check might have just saved you from a 
real nasty bug in your code.

--Justin

begin:vcard
begin:vcard
fn:Justin Noel
n:Noel;Justin
org:ICS;Engineering
adr:;;54B Middlesex Trpk;Bedford;MA;01730;USA
email;internet:justin@xxxxxxx
title:Sr. Consulting Engineer / Certified Qt Instructor
tel;work:(617) 621-0060
url:http://www.ics.com
version:2.1
end:vcard


Message 12 in thread

It looks to me like you might be doing a qobject_cast on a non-pointer...
 
It would help if you posted the offending line...
 
Scott

________________________________

From: Lingfa Yang [mailto:lingfa@xxxxxxx]
Sent: Thu 5/3/2007 11:10 AM
To: Qt Interest
Subject: What's wrong with Qt4.3.0beta compiler?



My codes work well in Qt4.1.1, but fail to compile in 4.3.0beta. Errors
are copied below:

c:\myQt\_gui\XbelTree.h(14) : error C2440: 'initializing' : cannot
convert from 'void' to 'int'
        Expressions of type void cannot be converted to other types
       
c:\Qt\4.3.0beta\include\QtCore\../../src\corelib\kernel\qobject.h(409) :
see reference to function template instantiation 'void
XbelTree::qt_check_for_QOBJECT_macro<TreeParser>(const T &) const' being
compiled
        with
        [
            T=TreeParser
        ]
        MainWindow.cc(152) : see reference to function template
instantiation 'T qobject_cast<TreeParser*>(QObject *)' being compiled
        with
        [
            T=TreeParser *
        ]

What's wrong with Qt4.3.0beta compiler?
Which version is the last safe version?

Thanks,
Lingfa

--
 [ signature omitted ]