Results 1 to 2 of 2

Thread: No static version of a QFileSystemWatcher/QObject possible?

  1. #1
    Join Date
    Apr 2008
    Posts
    39
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default No static version of a QFileSystemWatcher/QObject possible?

    Hello.

    This is a simplified version of the corresponding header file:
    Qt Code:
    1. #ifndef QU_H_
    2. #define QU_H_
    3.  
    4. #include <QObject>
    5. #include <QFileSystemWatcher>
    6.  
    7. class QU: QObject {
    8. Q_OBJECT
    9. public:
    10. QU(QObject *parent = 0);
    11. static QFileSystemWatcher Watcher;
    12. };
    13.  
    14. #endif /*QU_H_*/
    To copy to clipboard, switch view to plain text mode 
    And here the source file (QU.cpp):
    Qt Code:
    1. #include "QU.h"
    2.  
    3. QU::QU(QObject *parent): QObject(parent) {}
    To copy to clipboard, switch view to plain text mode 

    Well, the initialization of that static member variable is necessary, because otherwise there will be a "undefinied reference to" in the linker.

    But I cannot compile the QU.cpp. The error:
    QU.cpp: In copy constructor `QFileSystemWatcher::QFileSystemWatcher(const QFileSystemWatcher&)':
    ../../../../Tools/Qt/4.3.5/include/QtCore/../../src/corelib/kernel/qobject.h:292: error: `QObject::QObject(const QObject&)' is private
    QU.cpp:230: error: within this context
    What's going on? A static version of a QDir object works fine...

    Edit: Well, QDir() is not derived from QObject. Could it be that no QObject could be static because of the signal/slot concept?
    Last edited by youkai; 6th September 2008 at 10:22.

  2. #2
    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: No static version of a QFileSystemWatcher/QObject possible?

    The error says that you can't copy QObjects, not that it can't be static.

    Try:
    Qt Code:
    1. QFileSystemWatcher QU::Watcher;
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Designer doesn't load wwWidgets plugin
    By reimer in forum Installation and Deployment
    Replies: 21
    Last Post: 7th February 2009, 03:23
  2. Replies: 16
    Last Post: 23rd May 2008, 10:12
  3. Qt designer plugin errors on OSX Leopard
    By mpotocnik in forum Qt Tools
    Replies: 10
    Last Post: 21st January 2008, 09:45
  4. Distributing QT application for Mac OS
    By mb0 in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2007, 18:59
  5. Replies: 15
    Last Post: 21st April 2007, 17:46

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.