Qt-interest Archive, June 2007
[Qt4.3] Compile Error on Q_OBJECT in grandchild?
Message 1 in thread
I've recently moved from Qt4.2 to Qt4.3 (commercial license). (Compiles and executes fine on 4.2, won't compile on 4.3, using MSVC++2005 +SP1 +hotfix.)
It seems to be a problem with derivation:
class MyA : public QWidget {
Q_OBJECT
// ...other stuff
};
class MyB : public MyA {
Q_OBJECT // doesn't matter if here or not
// ...other stuff
};
class MyC : public MyB {
Q_OBJECT // <--- COMPILE ERROR
// ...other stuff
};
The error is:
error C2440: 'initializing' : cannot convert from 'void' to 'int'
In this case, I *must* have a Q_OBJECT in class "MyC" because it implements signals and slots. It implicitly inherits from QObject through its great-grandparent, QWidget, so it shouldn't be a problem. (In fact, on Qt4.3, if you remove the "Q_OBJECT" from "MyC", I get an error saying it's required -- that's a ?new error over Qt.4.2.)
All this code compiled and executed fine with Qt4.2 on the same compiler.
My problem seems similar to the qt-interest thread:
<http://lists.trolltech.com/qt-interest/2007-05/thread00122-0.html>
However, I don't know what to do about fixing this.
I had this problem before-and-after I installed MSVC++ SP1 and the Microsoft hotfix. Unless I can get this to compile, I have to move back to Qt4.2 (which would be a big disappointment because Qt4.3 looks really nice for some things I need).
Suggestions?
--charley
____________________________________________________________________________________
Luggage? GPS? Comic books?
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz
--
[ signature omitted ]
Message 2 in thread
Not sure what you mean by hotfix but if it's not what this snip is, you
should probably get it:
<snip>
From: Keith Esau <keith.esau@xxxxxxx>
Date: Jun 28, 2007 12:39 PM
Subject: Re: VS2005 SP1 Final Breaks Qt
To: Qt Interest <qt-interest@xxxxxxxxxxxxx>
The patch is now available without a call. I have an MSDN
subscription and signed in that way, so I don't know if that is
required.
The download in on this page:
<http://go.microsoft.com/fwlink/?linkid=87465>
It is about half way down, for the Visual C++ Compiler, with the
description:
FIX: Certain template code does not compile, and error C2244
occurs after you install Visual Studio 2005 Service Pack 1
Keith
</snip>
chris burke
phone: 617-621-0060 x195
email: cburke@xxxxxxx
skype: chris.burke0
Charley Bay wrote:
> I've recently moved from Qt4.2 to Qt4.3 (commercial license). (Compiles and executes fine on 4.2, won't compile on 4.3, using MSVC++2005 +SP1 +hotfix.)
>
> It seems to be a problem with derivation:
>
> class MyA : public QWidget {
> Q_OBJECT
> // ...other stuff
> };
> class MyB : public MyA {
> Q_OBJECT // doesn't matter if here or not
> // ...other stuff
> };
> class MyC : public MyB {
> Q_OBJECT // <--- COMPILE ERROR
> // ...other stuff
> };
>
> The error is:
> error C2440: 'initializing' : cannot convert from 'void' to 'int'
>
> In this case, I *must* have a Q_OBJECT in class "MyC" because it implements signals and slots. It implicitly inherits from QObject through its great-grandparent, QWidget, so it shouldn't be a problem. (In fact, on Qt4.3, if you remove the "Q_OBJECT" from "MyC", I get an error saying it's required -- that's a ?new error over Qt.4.2.)
>
> All this code compiled and executed fine with Qt4.2 on the same compiler.
>
> My problem seems similar to the qt-interest thread:
> <http://lists.trolltech.com/qt-interest/2007-05/thread00122-0.html>
> However, I don't know what to do about fixing this.
>
> I had this problem before-and-after I installed MSVC++ SP1 and the Microsoft hotfix. Unless I can get this to compile, I have to move back to Qt4.2 (which would be a big disappointment because Qt4.3 looks really nice for some things I need).
>
> Suggestions?
>
> --charley
>
>
>
>
>
> ____________________________________________________________________________________
> Luggage? GPS? Comic books?
> Check out fitting gifts for grads at Yahoo! Search
> http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
--
[ signature omitted ]
Message 3 in thread
using the Qt 4.3.0 and MSVC++2003 i don't get any error in your example.
Cheers,
Peter
> -----Original Message-----
> From: Charley Bay [mailto:charleyb123@xxxxxxxxx]
> Sent: Friday, June 29, 2007 2:24 PM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: [Qt4.3] Compile Error on Q_OBJECT in grandchild?
>
> I've recently moved from Qt4.2 to Qt4.3 (commercial license).
(Compiles
> and executes fine on 4.2, won't compile on 4.3, using MSVC++2005 +SP1
> +hotfix.)
>
> It seems to be a problem with derivation:
>
> class MyA : public QWidget {
> Q_OBJECT
> // ...other stuff
> };
> class MyB : public MyA {
> Q_OBJECT // doesn't matter if here or not
> // ...other stuff
> };
> class MyC : public MyB {
> Q_OBJECT // <--- COMPILE ERROR
> // ...other stuff
> };
--
[ signature omitted ]
Message 4 in thread
Thank you -- yes, that's the hotfix I installed:
For KBA 930198, VS80sp1-KB930859-X86-ENU.exe
I've re-installed it several times -- same behavior (won't compile, even after a "clean").
Strange. ;-(
--charley
----- Original Message ----
Chris Burke <cburke@xxxxxxx>
To: qt-interest@xxxxxxxxxxxxx
Cc: qt-interest@xxxxxxxxxxxxx
Sent: Friday, June 29, 2007 6:29:48 AM
Subject: Re: [Qt4.3] Compile Error on Q_OBJECT in grandchild?
Not sure what you mean by hotfix but if it's not what this snip is, you
should probably get it:
<snip>
From: Keith Esau <keith.esau@xxxxxxx>
Date: Jun 28, 2007 12:39 PM
Subject: Re: VS2005 SP1 Final Breaks Qt
To: Qt Interest <qt-interest@xxxxxxxxxxxxx>
The patch is now available without a call. I have an MSDN
subscription and signed in that way, so I don't know if that is
required.
The download in on this page:
<http://go.microsoft.com/fwlink/?linkid=87465>
It is about half way down, for the Visual C++ Compiler, with the
description:
FIX: Certain template code does not compile, and error C2244
occurs after you install Visual Studio 2005 Service Pack 1
Keith
</snip>
chris burke
phone: 617-621-0060 x195
email: cburke@xxxxxxx
skype: chris.burke0
Charley Bay wrote:
> I've recently moved from Qt4.2 to Qt4.3 (commercial license). (Compiles and executes fine on 4.2, won't compile on 4.3, using MSVC++2005 +SP1 +hotfix.)
>
> It seems to be a problem with derivation:
>
> class MyA : public QWidget {
> Q_OBJECT
> // ...other stuff
> };
> class MyB : public MyA {
> Q_OBJECT // doesn't matter if here or not
> // ...other stuff
> };
> class MyC : public MyB {
> Q_OBJECT // <--- COMPILE ERROR
> // ...other stuff
> };
>
> The error is:
> error C2440: 'initializing' : cannot convert from 'void' to 'int'
>
> In this case, I *must* have a Q_OBJECT in class "MyC" because it implements signals and slots. It implicitly inherits from QObject through its great-grandparent, QWidget, so it shouldn't be a problem. (In fact, on Qt4.3, if you remove the "Q_OBJECT" from "MyC", I get an error saying it's required -- that's a ?new error over Qt.4.2.)
>
> All this code compiled and executed fine with Qt4.2 on the same compiler.
>
> My problem seems similar to the qt-interest thread:
> <http://lists.trolltech.com/qt-interest/2007-05/thread00122-0.html>
> However, I don't know what to do about fixing this.
>
> I had this problem before-and-after I installed MSVC++ SP1 and the Microsoft hotfix. Unless I can get this to compile, I have to move back to Qt4.2 (which would be a big disappointment because Qt4.3 looks really nice for some things I need).
>
> Suggestions?
>
> --charley
____________________________________________________________________________________
Luggage? GPS? Comic books?
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz
--
[ signature omitted ]
Message 5 in thread
Post a snip of the code that causes the error.
chris burke
phone: 617-621-0060 x195
email: cburke@xxxxxxx
skype: chris.burke0
Charley Bay wrote:
> Thank you -- yes, that's the hotfix I installed:
>
> For KBA 930198, VS80sp1-KB930859-X86-ENU.exe
>
> I've re-installed it several times -- same behavior (won't compile, even after a "clean").
> Strange. ;-(
>
> --charley
>
>
> ----- Original Message ----
> Chris Burke <cburke@xxxxxxx>
> To: qt-interest@xxxxxxxxxxxxx
> Cc: qt-interest@xxxxxxxxxxxxx
> Sent: Friday, June 29, 2007 6:29:48 AM
> Subject: Re: [Qt4.3] Compile Error on Q_OBJECT in grandchild?
>
> Not sure what you mean by hotfix but if it's not what this snip is, you
> should probably get it:
>
> <snip>
>
> From: Keith Esau <keith.esau@xxxxxxx>
> Date: Jun 28, 2007 12:39 PM
> Subject: Re: VS2005 SP1 Final Breaks Qt
> To: Qt Interest <qt-interest@xxxxxxxxxxxxx>
>
> The patch is now available without a call. I have an MSDN
> subscription and signed in that way, so I don't know if that is
> required.
>
> The download in on this page:
>
> <http://go.microsoft.com/fwlink/?linkid=87465>
>
> It is about half way down, for the Visual C++ Compiler, with the
> description:
>
> FIX: Certain template code does not compile, and error C2244
> occurs after you install Visual Studio 2005 Service Pack 1
>
> Keith
>
> </snip>
>
> chris burke
> phone: 617-621-0060 x195
> email: cburke@xxxxxxx
> skype: chris.burke0
>
>
>
> Charley Bay wrote:
>
>> I've recently moved from Qt4.2 to Qt4.3 (commercial license). (Compiles and executes fine on 4.2, won't compile on 4.3, using MSVC++2005 +SP1 +hotfix.)
>>
>> It seems to be a problem with derivation:
>>
>> class MyA : public QWidget {
>> Q_OBJECT
>> // ...other stuff
>> };
>> class MyB : public MyA {
>> Q_OBJECT // doesn't matter if here or not
>> // ...other stuff
>> };
>> class MyC : public MyB {
>> Q_OBJECT // <--- COMPILE ERROR
>> // ...other stuff
>> };
>>
>> The error is:
>> error C2440: 'initializing' : cannot convert from 'void' to 'int'
>>
>> In this case, I *must* have a Q_OBJECT in class "MyC" because it implements signals and slots. It implicitly inherits from QObject through its great-grandparent, QWidget, so it shouldn't be a problem. (In fact, on Qt4.3, if you remove the "Q_OBJECT" from "MyC", I get an error saying it's required -- that's a ?new error over Qt.4.2.)
>>
>> All this code compiled and executed fine with Qt4.2 on the same compiler.
>>
>> My problem seems similar to the qt-interest thread:
>> <http://lists.trolltech.com/qt-interest/2007-05/thread00122-0.html>
>> However, I don't know what to do about fixing this.
>>
>> I had this problem before-and-after I installed MSVC++ SP1 and the Microsoft hotfix. Unless I can get this to compile, I have to move back to Qt4.2 (which would be a big disappointment because Qt4.3 looks really nice for some things I need).
>>
>> Suggestions?
>>
>> --charley
>>
>
>
>
>
>
> ____________________________________________________________________________________
> Luggage? GPS? Comic books?
> Check out fitting gifts for grads at Yahoo! Search
> http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
--
[ signature omitted ]
Message 6 in thread
Ok, strange -- I've found the trigger for the compile error (see previous message below for context):
void SomeClass::myslot_doSomething(const QAbstractButton& /*button*/)
{
// ...TRIGGERS COMPILE ERROR IN "MyC.hpp" IN 4.3,
// COMPILES AND RUNS FINE IN 4.2...
MyC* myc_sender = qobject_cast<MyC*>(sender());
// ...do stuff
}
Now the previous thread makes sense: Qt4.3 is apparently a bit more strict regarding qobject_cast<>. However, I expected it to work because it's single inheritance from QObject (through QWidget), and I have a Q_OBJECT in each header all-the-way down the hierarchy.
This was hard to track down, because the qobject_cast<> in another file triggered the compile error in the "MyC" header.
(I understand using "sender()" isn't very graceful, but it seemed to be useful in this case, and I found the code snippet in a Qt example -- is this use deprecated in Qt4.3?)
Looking into QObject.h, it appears the trolls in Qt4.3 use a syntax closer to the following:
reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(object));
What's the appropriate way in Qt4.3 to get the user-type'd "sender()" within a slot?
Thanks!
--charley
----- Original Message ----
From: Chris Burke <cburke@xxxxxxx>
Post a snip of the code that causes the error.
chris burke
phone: 617-621-0060 x195
email: cburke@xxxxxxx
skype: chris.burke0
>----------------------------------------
> <snip, install MS SP1 and hotfix for KBA 930198>
> <http://go.microsoft.com/fwlink/?linkid=87465>
>
> It is about half way down, for the Visual C++ Compiler, with the
> description:
>
> FIX: Certain template code does not compile, and error C2244
> occurs after you install Visual Studio 2005 Service Pack 1
> ----------------------------------------
> Charley Bay wrote:
>
>> I've recently moved from Qt4.2 to Qt4.3 (commercial license). (Compiles and executes fine on 4.2, won't compile on 4.3, using MSVC++2005 +SP1 +hotfix.)
>>
>> It seems to be a problem with derivation:
>>
>> class MyA : public QWidget {
>> Q_OBJECT
>> // ...other stuff
>> };
>> class MyB : public MyA {
>> Q_OBJECT // doesn't matter if here or not
>> // ...other stuff
>> };
>> class MyC : public MyB {
>> Q_OBJECT // <--- COMPILE ERROR
>> // ...other stuff
>> };
>>
>> The error is:
>> error C2440: 'initializing' : cannot convert from 'void' to 'int'
>>
>> In this case, I *must* have a Q_OBJECT in class "MyC" because it implements signals and slots. It implicitly inherits from QObject through its great-grandparent, QWidget, so it shouldn't be a problem. (In fact, on Qt4.3, if you remove the "Q_OBJECT" from "MyC", I get an error saying it's required -- that's a ?new error over Qt.4.2.)
>>
>> All this code compiled and executed fine with Qt4.2 on the same compiler.
>>
>> My problem seems similar to the qt-interest thread:
>> <http://lists.trolltech.com/qt-interest/2007-05/thread00122-0.html>
>> However, I don't know what to do about fixing this.
>>
>> I had this problem before-and-after I installed MSVC++ SP1 and the Microsoft hotfix. Unless I can get this to compile, I have to move back to Qt4.2 (which would be a big disappointment because Qt4.3 looks really nice for some things I need).
>>
>> Suggestions?
>>
>> --charley
>>
____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/
--
[ signature omitted ]