Results 1 to 4 of 4

Thread: problem in declaring QDirModel

  1. #1
    Join Date
    Jul 2008
    Location
    Bangalore
    Posts
    10
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default problem in declaring QDirModel

    I write a class which is extended from QWidget and Now i declare a QDirModel object in .h file and it instantiated in My class contructor... when i compile it gives the following error.. I include all the things whic are necessary..

    model.h:18: error: ISO C++ forbids declaration of 'QDirModel' with no type
    model.h:18: error: expected ';' before '*' token
    model.cpp: In constructor 'DirModel:irModel(QWidget*)':
    model.cpp:10: error: 'iModel' was not declared in this scope
    model.cpp:10: error: expected type-specifier before 'QDirModel'
    model.cpp:10: error: expected `;' before 'QDirModel'
    model.cpp: At global scope:
    code is :

    Qt Code:
    1. class DirModel: public QWidget
    2. {
    3.  
    4. public:
    5. DirModel(QWidget* aParent);
    6. ~DirModel();
    7.  
    8. void AddFolder(const QString& aFolderName,int aParent = 0);
    9.  
    10. public:
    11. QDirModel* iModel;
    12. QTreeView* iView;
    13. int iFolderId;
    14. };
    15.  
    16.  
    17. DirModel::DirModel(QWidget* aParent)
    18. :QWidget(aParent)
    19. {
    20. iModel = new QDirModel(this);
    21. iModel->setReadOnly(false);
    22.  
    23. iView = new QTreeView(this);
    24. iView->setModel(iModel);
    25. iView->setRootIndex( iModel->index(QString( "/home/randy" ) ) );
    26. }
    27.  
    28.  
    29. DirModel::~DirModel()
    30. {
    31.  
    32. }
    33.  
    34. void DirModel::AddFolder(const QString& aFolderName,int aParent)
    35. {
    36. // iModel->mkdir(aParent,aFolderName);
    37.  
    38. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 9th December 2008 at 16:52. Reason: missing [code] tags

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: problem in declaring QDirModel

    You should add
    Qt Code:
    1. class QDirModel;
    To copy to clipboard, switch view to plain text mode 

    Before DirModel class declaration. Or just include it.
    I'm a rebel in the S.D.G.

  3. #3
    Join Date
    Jul 2008
    Location
    Bangalore
    Posts
    10
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: problem in declaring QDirModel

    i try the above two options
    class QDirModel;
    and also i include that header file...
    even it gives the same errors above shown.

  4. #4
    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: problem in declaring QDirModel

    Could you attach the header and source file or something? Then we can spot it immediately. Otherwise we just have to keep guessing.
    J-P Nurmi

Similar Threads

  1. QTreeView and QDirmodel 's problem?
    By ggs0110 in forum Qt Programming
    Replies: 8
    Last Post: 31st July 2012, 12:11
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. QDirModel and QTreeView cut and paste
    By Micawber in forum Qt Programming
    Replies: 4
    Last Post: 28th May 2008, 20:16
  4. Replies: 2
    Last Post: 8th April 2008, 10:35
  5. problem declaring a class
    By mickey in forum General Programming
    Replies: 1
    Last Post: 26th May 2006, 18:12

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.