| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"Fisherss" |
| Date: |
27 Dec 2007 03:32:50 AM |
| Object: |
Why should I declare again ? |
Hi all
I am a C++ newbie and now have a problem with this:
=====
#include <QtGui>
class QLabel;
=====
I am pretty sure that "QLabel" was defined in <QtGui> but I can't use
this class without "class QLabel", why should I declare it again?
.
|
|
| User: "Duane Hebert" |
|
| Title: Re: Why should I declare again ? |
27 Dec 2007 08:39:13 AM |
|
|
"Fisherss" <fisherss@gmail.com> wrote in message
news:fl001i$jgb$1@news.cn99.com...
Hi all
I am a C++ newbie and now have a problem with this:
=====
#include <QtGui>
class QLabel;
=====
I am pretty sure that "QLabel" was defined in <QtGui> but I can't use this
class without "class QLabel", why should I declare it again?
QtGui is the library. You need to link it, not include it.
If you could it would not be a good idea anyway.
How you link it depends on your tools,
For QLabel, forward declare it in the header as you show
and in the cpp file, add the #include <QLabel>
.
|
|
|
| User: "Fisherss" |
|
| Title: Re: Why should I declare again ? |
28 Dec 2007 09:25:45 PM |
|
|
Duane Hebert wrote:
"Fisherss" <fisherss@gmail.com> wrote in message
news:fl001i$jgb$1@news.cn99.com...
Hi all
I am a C++ newbie and now have a problem with this:
=====
#include <QtGui>
class QLabel;
=====
I am pretty sure that "QLabel" was defined in <QtGui> but I can't use this
class without "class QLabel", why should I declare it again?
QtGui is the library. You need to link it, not include it.
If you could it would not be a good idea anyway.
How you link it depends on your tools,
For QLabel, forward declare it in the header as you show
and in the cpp file, add the #include <QLabel>
Thanks, I think this should be the right solution.
.
|
|
|
|
|
| User: "Pavel Shved" |
|
| Title: Re: Why should I declare again ? |
27 Dec 2007 04:04:08 AM |
|
|
On 27 =C4=C5=CB, 12:32, Fisherss <fishe...@gmail.com> wrote:
Hi all
I am a C++ newbie and now have a problem with this:
=3D=3D=3D=3D=3D
#include <QtGui>
class QLabel;
=3D=3D=3D=3D=3D
I am pretty sure that "QLabel" was defined in <QtGui> but I can't use
this class without "class QLabel", why should I declare it again?
=46rom FAQ: provide minimal *compilable* example that illustrates the
problem. What do you mean by `use' here?
For now: are you sure that you've *really* have the class declared?
And what is that QtGui mythical header that surely not belongs to Qt
includes as they're named with lowercase letters and .h in the end?
Or... You try to include a *directory* full of headers (which QtGui
is)?
.
|
|
|
| User: "=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=" |
|
| Title: Re: Why should I declare again ? |
27 Dec 2007 06:15:45 AM |
|
|
On 2007-12-27 11:04, Pavel Shved wrote:
On 27 дек, 12:32, Fisherss <fishe...@gmail.com> wrote:
Hi all
I am a C++ newbie and now have a problem with this:
=====
#include <QtGui>
class QLabel;
=====
I am pretty sure that "QLabel" was defined in <QtGui> but I can't use
this class without "class QLabel", why should I declare it again?
From FAQ: provide minimal *compilable* example that illustrates the
problem. What do you mean by `use' here?
For now: are you sure that you've *really* have the class declared?
And what is that QtGui mythical header that surely not belongs to Qt
includes as they're named with lowercase letters and .h in the end?
Or... You try to include a *directory* full of headers (which QtGui
is)?
And: What makes you think you should declare QLable?
--
Erik Wikström
.
|
|
|
| User: "Fisherss" |
|
| Title: Re: Why should I declare again ? |
28 Dec 2007 09:24:40 PM |
|
|
Erik Wikström wrote:
On 2007-12-27 11:04, Pavel Shved wrote:
On 27 дек, 12:32, Fisherss <fishe...@gmail.com> wrote:
Hi all
I am a C++ newbie and now have a problem with this:
=====
#include <QtGui>
class QLabel;
=====
I am pretty sure that "QLabel" was defined in <QtGui> but I can't use
this class without "class QLabel", why should I declare it again?
From FAQ: provide minimal *compilable* example that illustrates the
problem. What do you mean by `use' here?
For now: are you sure that you've *really* have the class declared?
And what is that QtGui mythical header that surely not belongs to Qt
includes as they're named with lowercase letters and .h in the end?
Or... You try to include a *directory* full of headers (which QtGui
is)?
And: What makes you think you should declare QLable?
The compiler gave me a message that QLable was not declared.
.
|
|
|
| User: "=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=" |
|
| Title: Re: Why should I declare again ? |
29 Dec 2007 05:59:29 AM |
|
|
On 2007-12-29 04:24, Fisherss wrote:
Erik Wikström wrote:
On 2007-12-27 11:04, Pavel Shved wrote:
On 27 дек, 12:32, Fisherss <fishe...@gmail.com> wrote:
Hi all
I am a C++ newbie and now have a problem with this:
=====
#include <QtGui>
class QLabel;
=====
I am pretty sure that "QLabel" was defined in <QtGui> but I can't use
this class without "class QLabel", why should I declare it again?
From FAQ: provide minimal *compilable* example that illustrates the
problem. What do you mean by `use' here?
For now: are you sure that you've *really* have the class declared?
And what is that QtGui mythical header that surely not belongs to Qt
includes as they're named with lowercase letters and .h in the end?
Or... You try to include a *directory* full of headers (which QtGui
is)?
And: What makes you think you should declare QLable?
The compiler gave me a message that QLable was not declared.
In your case that probably means that you should include <qlabel.h> and
not just make a forward declaration.
--
Erik Wikström
.
|
|
|
| User: "Duane Hebert" |
|
| Title: Re: Why should I declare again ? |
29 Dec 2007 03:17:45 PM |
|
|
"Erik Wikström" <Erik-wikstrom@telia.com> wrote in message
news:BEqdj.2168$R_4.1650@newsb.telia.net...
On 2007-12-29 04:24, Fisherss wrote:
Erik Wikström wrote:
On 2007-12-27 11:04, Pavel Shved wrote:
On 27 ???, 12:32, Fisherss <fishe...@gmail.com> wrote:
Hi all
I am a C++ newbie and now have a problem with this:
=====
#include <QtGui>
class QLabel;
=====
I am pretty sure that "QLabel" was defined in <QtGui> but I can't use
this class without "class QLabel", why should I declare it again?
From FAQ: provide minimal *compilable* example that illustrates the
problem. What do you mean by `use' here?
For now: are you sure that you've *really* have the class declared?
And what is that QtGui mythical header that surely not belongs to Qt
includes as they're named with lowercase letters and .h in the end?
Or... You try to include a *directory* full of headers (which QtGui
is)?
And: What makes you think you should declare QLable?
The compiler gave me a message that QLable was not declared.
In your case that probably means that you should include <qlabel.h> and
not just make a forward declaration.
Starting with Qt4, the trolls changed their includes to use the
<QLabel> format. Since he has <QtGui> it seems that
he's using Qt4.
.
|
|
|
|
|
|
|
|

|
Related Articles |
|
|