Results 1 to 6 of 6

Thread: error:invalid use of undefined type 'struct QWorkspace'

  1. #1
    Join Date
    Jul 2007
    Posts
    25
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Unhappy error:invalid use of undefined type 'struct QWorkspace'

    hi,

    idk if somebody has tried this before, but I had first time opportunity to use Qworkspace API in my program and the compiler is throwing out this puzzling error each time::
    error:invalid use of undefined type 'struct QWorkspace'

    I've included the required QWorkspace header file properly in my header file, but still I'm getting this error, code snippets are as follows:
    Header file snippet is::

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5.  
    6. class QWorkspace;
    7.  
    8. class MainWindow : public QMainWindow
    9. {
    10. Q_OBJECT
    11. public:
    12. MainWindow();
    13. private:
    14. QWorkspace *workspace;
    15.  
    16. };
    17. #endif
    To copy to clipboard, switch view to plain text mode 

    CPP file snippet is ::

    Qt Code:
    1. #include <QtGui>
    2.  
    3. #include "test.h"
    4.  
    5. MainWindow::MainWindow()
    6. {
    7. workspace = new QWorkspace;
    8. setCentralWidget(workspace);
    9.  
    10. /*some stupid code of application*/
    11.  
    12. }
    To copy to clipboard, switch view to plain text mode 

    is there anything I'm missing out in that?



    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: error:invalid use of undefined type 'struct QWorkspace'

    Are you sure this is exactly the same code you were compiling? It's just that I can't see anything syntactically wrong and the includes sure are sufficient...
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: error:invalid use of undefined type 'struct QWorkspace'

    The following code which is infact the above classes put in a single file compiles and executes just fine on my system.

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5.  
    6. class QWorkspace;
    7.  
    8. class MainWindow : public QMainWindow
    9. {
    10. Q_OBJECT
    11. public:
    12. MainWindow();
    13. private:
    14. QWorkspace *workspace;
    15.  
    16. };
    17. #endif
    18.  
    19.  
    20. #include <QtGui>
    21.  
    22. MainWindow::MainWindow()
    23. {
    24. workspace = new QWorkspace;
    25. setCentralWidget(workspace);
    26.  
    27. /*some stupid code of application*/
    28.  
    29. }
    30.  
    31. int main(int argc, char **argv)
    32. {
    33. QApplication app(argc, argv);
    34. MainWindow mw;
    35. mw.show();
    36. return app.exec();
    37. }
    38.  
    39. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jul 2007
    Posts
    25
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: error:invalid use of undefined type 'struct QWorkspace'

    Thanks jpn and momesana for your quick and helpful replies.
    Actually it worked out later on, i don't know what was the problem initially when I was compiling it, but it got compiled well, after giving it second shot.
    I guess may be there was linking libraries problem with the Makefile I created on my own >:<

    Thanks and Regards

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: error:invalid use of undefined type 'struct QWorkspace'

    Quote Originally Posted by LiCodeX View Post
    I guess may be there was linking libraries problem with the Makefile I created on my own
    Wow, does somebody still write makefiles by hand these days. Why not use qmake which would do it for you?
    J-P Nurmi

  6. #6
    Join Date
    Jul 2007
    Posts
    25
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: error:invalid use of undefined type 'struct QWorkspace'

    Quote Originally Posted by jpn View Post
    Wow, does somebody still write makefiles by hand these days. Why not use qmake which would do it for you?
    yeah it was unnecessary futile attempt to get it done on my own.
    sometimes getting word done by easy utility bothers me a bit


    Thanks

Similar Threads

  1. dummy question(Error)
    By Masih in forum Qt Programming
    Replies: 12
    Last Post: 19th July 2007, 23:38
  2. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 14:28
  3. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 19:15
  4. Strange error while using Q3Canvas
    By Kapil in forum Newbie
    Replies: 13
    Last Post: 15th June 2006, 19:36

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.