Results 1 to 6 of 6

Thread: request for member `show' in `w', which is of non-aggregate type `MainForm*

  1. #1
    Join Date
    Jan 2006
    Posts
    46
    Qt products
    Qt3
    Platforms
    Unix/X11

    Question request for member `show' in `w', which is of non-aggregate type `MainForm*

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: request for member `show' in `w', which is of non-aggregate type `MainForm*

    Did you include the header file with your MainForm definition?

  3. #3
    Join Date
    Jan 2006
    Posts
    46
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: request for member `show' in `w', which is of non-aggregate type `MainForm*

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: request for member `show' in `w', which is of non-aggregate type `MainForm*

    Are you sure you get this error with the version of main() function you have posted above?

  5. #5
    Join Date
    Jan 2006
    Posts
    46
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: request for member `show' in `w', which is of non-aggregate type `MainForm*

    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

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: request for member `show' in `w', which is of non-aggregate type `MainForm*

    Quote Originally Posted by Mariane
    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:
    Qt Code:
    1. int main( int argc, char ** argv )
    2. {
    3. QApplication a( argc, argv );
    4. MainForm w;
    5. w.show();
    6. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    7. return a.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

    It would occur if you had:
    Qt Code:
    1. MainForm *w = new MainForm();
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. MainForm *w;
    To copy to clipboard, switch view to plain text mode 
    .

Similar Threads

  1. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  2. dummy question(Error)
    By Masih in forum Qt Programming
    Replies: 12
    Last Post: 19th July 2007, 23:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.