Qt-interest Archive, May 2007
Visual Studio 2003 & moc tie-in
Message 1 in thread
Hi everyone,
I'm porting someone's project from Qt3 to 4 and have used as a starting
point their VS 2003 project. So far so good, but I'm having trouble with
moc. When I rebuild the project I see a number of statements like this in
the output window:
Deleting intermediate files and output files for project 'ModelingTool',
configuration 'Debug|Win32'.
Moc'ing TextureViewer.h...
Moc'ing TextureDisplay.h...
Moc'ing ScalingDisplay.h...
Moc'ing RotationDisplay.h...
Moc'ing PartsChooser.h...
etc. The problem is, not all of the .h files in the project are being
Moc'ed, for some reason. I'd like to add the others to moc's "to do" list.
I've been looking through the project, trying to find the pre build event
that calls the moc compiler, but I'm having no luck finding where moc and
Visual Studio tie together. Could someone point me in the right direction
here? Thanks!
--
[ signature omitted ]
Message 2 in thread
> etc. The problem is, not all of the .h files in the project are being
> Moc'ed, for some reason. I'd like to add the others to moc's "to do" list.
I assume you mean "no output file is generated"? I had this problem when I
used slashes
QTDIR=d:/source/qt4
instead of backslashes
QTDIR=d:\sources\qt4.
With the first QTDIR, qmake called moc, but no file was generated anymore.
--
[ signature omitted ]
Message 3 in thread
Hi,
Thanks for the reply. I don't know if QTDIR is the problem here, as most of
the .h files in the VS2003 project are being moc'ed when the project is
rebuilt. It's only one or two that aren't for some reason.
Jim
"J. Preiss" <auba@xxxxxxx> wrote in message
news:200705132249.31797.auba@xxxxxxxxxx
>> etc. The problem is, not all of the .h files in the project are being
>> Moc'ed, for some reason. I'd like to add the others to moc's "to do"
>> list.
>
> I assume you mean "no output file is generated"? I had this problem when I
> used slashes
> QTDIR=d:/source/qt4
> instead of backslashes
> QTDIR=d:\sources\qt4.
>
> With the first QTDIR, qmake called moc, but no file was generated anymore.
>
> --
> 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 4 in thread
Jim Bancroft wrote:
> Hi,
>
> Thanks for the reply. I don't know if QTDIR is the problem here, as most of
> the .h files in the VS2003 project are being moc'ed when the project is
> rebuilt. It's only one or two that aren't for some reason.
>
> Jim
>
>
> "J. Preiss" <auba@xxxxxxx> wrote in message
> news:200705132249.31797.auba@xxxxxxxxxx
>>> etc. The problem is, not all of the .h files in the project are being
>>> Moc'ed, for some reason. I'd like to add the others to moc's "to do"
>>> list.
>> I assume you mean "no output file is generated"? I had this problem when I
>> used slashes
>> QTDIR=d:/source/qt4
>> instead of backslashes
>> QTDIR=d:\sources\qt4.
>>
>> With the first QTDIR, qmake called moc, but no file was generated anymore.
>>
Are you using qmake? Do all of the files that need to be moc'ed have the
Q_OBJECT macro in private section of the class definition?
>> --
>> 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 5 in thread
"Jim Bancroft" <sdfsk@xxxxxxx> wrote in message
news:f28lh2$c3t$1@xxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> Thanks for the reply. I don't know if QTDIR is the problem here, as most
> of the .h files in the VS2003 project are being moc'ed when the project is
> rebuilt. It's only one or two that aren't for some reason.
If you have VS integration, then you don't need to worry about QTDIR.
In fact, if you have multiple versions of Qt, defining QTDIR in your
environment can possibly cause problems. From the IDE, switching
to the version of Qt that you want to build with takes care of this.
Since most of your files are getting moc'd, this seems to be
working.
For the moc problem, make sure that the header files are included
in your project. Find them in the project tree. When you right click
on a header file that has Q_OBJECT defined, you should see a
compile option. You can choose this to moc the file manually.
If this isn't available, or if the moc fails, try removing the header
from the project and adding it back. Make sure that if you try to
add it back, you highlight the project in the solution explorer and
choose add (don't just add it to the header list)
We had a few of these when converting from Qt3 to Qt4. Normally just
deleting the header and adding it back solved it. I think that I had one
project that I had to recreate from scratch.
HTH
--
[ signature omitted ]
Message 6 in thread
Thanks very much for your help. I double-checked, and the files that aren't
being moc'ed do not have the "compile" option available to them when I
right-click, just as you suspected. What I can't figure out is why that
would be, since they do have Q_OBJECT defined in them, just like the other
header files.
Here's an example of a "bad" header file, at least the beginning of it.
Notice that it has Q_OBJECT defined, just as the "good" header files do:
#ifndef _SETTINGSDIALOG_H_
#define _SETTINGSDIALOG_H_
#include <qdialog.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qstringlist.h>
#include <qlayout.h>
class SettingsDialog
: public QDialog
{
Q_OBJECT
public:
SettingsDialog(QString fileName, QString pictureDir, QWidget *parent =
0, const char *name = 0); // constructor
~SettingsDialog(void); // destructor
signals:
<snip>
Any ideas why this file doesn't have the compile option enabled, yet others
do? AFAIK the style of both the "good" and "bad" headers follow the same
pattern and I can;t tell why some work and a few others don't.
--
[ signature omitted ]
Message 7 in thread
> -----Original Message-----
> From: Jim Bancroft [mailto:sdfsk@xxxxxxx]
> Sent: Monday, May 14, 2007 10:06 PM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Re: Visual Studio 2003 & moc tie-in
>
> Thanks very much for your help. I double-checked, and the files that
> aren't
> being moc'ed do not have the "compile" option available to them when I
> right-click, just as you suspected. What I can't figure out is why
that
> would be, since they do have Q_OBJECT defined in them, just like the
other
> header files.
>
> Here's an example of a "bad" header file, at least the beginning of
it.
> Notice that it has Q_OBJECT defined, just as the "good" header files
do:
>
>
> #ifndef _SETTINGSDIALOG_H_
> #define _SETTINGSDIALOG_H_
> #include <qdialog.h>
> #include <qlabel.h>
> #include <qlineedit.h>
> #include <qpushbutton.h>
> #include <qstringlist.h>
> #include <qlayout.h>
> class SettingsDialog
> : public QDialog
> {
> Q_OBJECT
> public:
> SettingsDialog(QString fileName, QString pictureDir, QWidget
*parent =
> 0, const char *name = 0); // constructor
> ~SettingsDialog(void); // destructor
> signals:
>
> <snip>
>
> Any ideas why this file doesn't have the compile option enabled, yet
> others
> do? AFAIK the style of both the "good" and "bad" headers follow the
same
> pattern and I can;t tell why some work and a few others don't.
It was probably added by hand to the project... Re-run qmake...
Scott
--
[ signature omitted ]
Message 8 in thread
Jim Bancroft wrote:
> Thanks very much for your help. I double-checked, and the files that aren't
> being moc'ed do not have the "compile" option available to them when I
> right-click, just as you suspected. What I can't figure out is why that
> would be, since they do have Q_OBJECT defined in them, just like the other
> header files.
>
>
Right click on the file and look at the 'properties' field. Is there a
valid custom build step to
moc the file? If there is then the compile option should be available.
If not, then VS hasn't
recognised this file correctly, try removing it and adding it back.
- Keith
--
[ signature omitted ]
Message 9 in thread
"Jim Bancroft" <sdfsk@xxxxxxx> wrote in message
news:f2bf43$gma$1@xxxxxxxxxxxxxxxxxxxxx
> Thanks very much for your help. I double-checked, and the files that
> aren't being moc'ed do not have the "compile" option available to them
> when I right-click, just as you suspected. What I can't figure out is why
> that would be, since they do have Q_OBJECT defined in them, just like the
> other header files.
>
> Here's an example of a "bad" header file, at least the beginning of it.
> Notice that it has Q_OBJECT defined, just as the "good" header files do:
>
>
> #ifndef _SETTINGSDIALOG_H_
> #define _SETTINGSDIALOG_H_
> #include <qdialog.h>
> #include <qlabel.h>
> #include <qlineedit.h>
> #include <qpushbutton.h>
> #include <qstringlist.h>
> #include <qlayout.h>
> class SettingsDialog
> : public QDialog
> {
> Q_OBJECT
> public:
> SettingsDialog(QString fileName, QString pictureDir, QWidget *parent =
> 0, const char *name = 0); // constructor
> ~SettingsDialog(void); // destructor
> signals:
>
> <snip>
>
> Any ideas why this file doesn't have the compile option enabled, yet
> others do? AFAIK the style of both the "good" and "bad" headers follow
> the same pattern and I can;t tell why some work and a few others don't.
Try removing the file and then adding it back to the project.
I'm not sure exactly the cause but I had this with a few headers
when updating the project. Maybe the generated files path
is incorrect or something.
--
[ signature omitted ]