[Qt-interest] Communication Problem
Sean Harmer
sean.harmer at maps-technology.com
Fri May 15 12:27:42 CEST 2009
Hi,
On Friday 15 May 2009 11:20:31 Sujan Dasmahapatra wrote:
> When I include tablewidget.h in mainwindow.h and mainwindow.h in
> tablewidget.h I am getting the following error.
> ///////////////////////////////////////////////////////////////////////////
>//////////////////////////////////////// In file included from
> tablewidget.h:9,
> from tablewidget.cpp:3:
> mainwindow.h:104: error: ISO C++ forbids declaration of `TableWidget' with
> no type mainwindow.h:104: error: expected `;' before '*' token
> make: *** [obj/tablewidget.o] Error 1
> ///////////////////////////////////////////////////////////////////////////
>//////////////////////////// Kind Regards,
Just store a pointer to the MainWindow in your TableWidget and vice versa.
That way you only need forward declarations of the other class in each header
file.
i.e. in mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
class TableWidget;
class MainWindow {
private:
TableWidget* m_tableWidget;
<other mainwindow stuff>
};
#endif
then in tablewidget.h
#ifndef TABLEWIDGET_H
#define TABLEWIDGET_H
class MainWindow;
class TableWidget {
private:
MainWindow* m_mainWindow;
<other TableWidget stuff>
}
#endif
Then when you need functions from the other class just #include the header
file in your .cpp implementation files.
HTH,
Sean
> Sujan Dasmahapatra
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Srdjan Todorovic
> Sent: Friday, May 15, 2009 3:47 PM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Communication Problem
>
> 2009/5/15 Sujan Dasmahapatra <sdh at lmglasfiber.com>:
> > Dear friends
> >
> > I’m sorry this is a C++ question.
> >
> > I have two classes MainWindow and TableWidget…..I want to communicate in
> > both directions.Can I include MainWindow in TableWidget and TableWidget
> > in MainWindow…….Its giving error…….what is the solution can anyone plss
> > tell me ??
>
> I don't understand what you mean by this. Can you provide us with more
> information?
> An exact error message or something, so we don't have to forever keep
> guessing what the problem with your code is.
>
> Srdjan
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list