View Full Version : request for member `show' in `w', which is of non-aggregate type `MainForm*
Mariane
28th January 2006, 22:11
I tried using designer to draw a main window in which to include my widget.
But it won't compile :
error: request for member `show' in `w', which is of non-aggregate
type `MainForm*'
Below is the code and commented out are things I've tried...
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
MainForm w;
// MainForm *w = new MainForm;
// MainForm w = new MainForm;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
(I've done the tutorial 2 of the designer and EXACTLY THE SAME main.cpp
compiles fine...)
Mariane
wysota
28th January 2006, 22:23
Did you include the header file with your MainForm definition?
Mariane
28th January 2006, 23:01
I've got :
#include <qapplication.h>
#include <qvariant.h>
#include <qpixmap.h>
#include <qmainwindow.h>
#include "mainform.h"
as includes in main.cpp... did I forget one?
Mariane
jacek
28th January 2006, 23:48
Are you sure you get this error with the version of main() function you have posted above?
Mariane
29th January 2006, 17:23
Quite sure, yes. I don't know what I did wrong, though... Maybe I changed
the name of the form after having done "new main.cpp" and this confused
it?
Today I tried using the designer and doing qmake make and "run" after
every change I made. If it compiled, I would save all in another directory,
if it didn't compile I would delete all, close designer, copy back all the files
and re-open the designer.
Once I lost the icon toolbar, once I lost the icon pictures, but I got there in
the end :)
What does "non-aggregate" mean, anyway?
Thank you all.
Mariane
jacek
29th January 2006, 18:00
What does "non-aggregate" mean, anyway?
It means that it's not a struct or class. For example int, char, pointer etc.
The problem is that this error shouldn't happen with such main() function:
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
MainForm w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
It would occur if you had:
MainForm *w = new MainForm();
or
MainForm *w;.
Powered by vBulletin® Version 4.2.5 Copyright © 2023 vBulletin Solutions Inc. All rights reserved.