473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 <QtGuibut I can't use
this class without "class QLabel", why should I declare it again?
Dec 27 '07 #1
7 1354
On 27 ÄÅË, 12:32, Fisherss <fishe...@gmail.comwrote:
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 <QtGuibut 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)?

Dec 27 '07 #2
On 2007-12-27 11:04, Pavel Shved wrote:
On 27 дек, 12:32, Fisherss <fishe...@gmail.comwrote:
>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 <QtGuibut 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
Dec 27 '07 #3

"Fisherss" <fi******@gmail.comwrote in message
news:fl**********@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 <QtGuibut 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>


Dec 27 '07 #4
Erik Wikström wrote:
On 2007-12-27 11:04, Pavel Shved wrote:
>On 27 дек, 12:32, Fisherss <fishe...@gmail.comwrote:
>>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 <QtGuibut 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.
Dec 29 '07 #5
Duane Hebert wrote:
"Fisherss" <fi******@gmail.comwrote in message
news:fl**********@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 <QtGuibut 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.
Dec 29 '07 #6
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.comwrote:
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 <QtGuibut 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.hand
not just make a forward declaration.

--
Erik Wikström
Dec 29 '07 #7

"Erik Wikström" <Er***********@telia.comwrote in message
news:BE*****************@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.comwrote:
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 <QtGuibut 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.hand
not just make a forward declaration.
Starting with Qt4, the trolls changed their includes to use the
<QLabelformat. Since he has <QtGuiit seems that
he's using Qt4.
Dec 29 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Black | last post by:
Hi, Suppose I have a class, class MyClass{ public: MyClass(); MyClass(MyClass); int func(); };
6
by: David T. Ashley | last post by:
Hi, In my project, I typically declare and define variables in the .H file, i.e. DECMOD_MAIN UINT8 can_message_201_status_global #ifdef MODULE_MAIN = HAS_NEVER_BEEN_RECEIVED #endif ;
24
by: Desmond Cassidy | last post by:
Hi, I don't know whether this is the correct place to ask this question..anyway here goes... I have a large solution with about 300 .vb files split into 9 projects VB.net Framework 1.1 WinXP...
10
by: Bob Hollness | last post by:
Hi all. I have a Sub that calls another sub. Both subs use a common object, so I used Public to declare it at the top of the module, as below. Public Writer As StreamWriter =...
23
by: mark.moore | last post by:
I know this has been asked before, but I just can't find the answer in the sea of hits... How do you forward declare a class that is *not* paramaterized, but is based on a template class? ...
6
by: John Bailo | last post by:
I created a sproc with 3 input parameters and one output parameter. I want to test it in the "Run SQL Scripts" app of Navigator. I wrote this code: DECLARE RTNDATE CHAR(10) DEFAULT ''; CALL...
6
by: Michael | last post by:
Hi. I am trying to declare variables based on DB column. I have a table with 2 columns: "varname" and "varvalue". values for example: varName: 'varPhone' varValue: '450-111-2222' During the...
1
by: okonita | last post by:
Hi all, My environment is DB2 UDBv8.2 on Windows and Linux. I am getting a lot of errors on the script you see below. Some of the error I am geting are: ...
5
by: dancer | last post by:
Using ASP.net 1.1 and VB Is it possible to declare variables in their own subroutine? I had my DIM statements within a sub that worked just fine. I wanted to be able to use them in another...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.