Results 1 to 3 of 3

Thread: operator=new ClassObj() is not recognized

  1. #1
    Join Date
    Jan 2011
    Location
    Australia
    Posts
    44
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default operator=new ClassObj() is not recognized

    i tried to make inline class using following header:
    Qt Code:
    1. #include <QString>
    2. #include <QFile>
    3. #include <QThread>
    4.  
    5. class _File : public QFile
    6.  
    7.  
    8. {
    9. Q_OBJECT
    10. public:
    11.  
    12. _File();
    13. _File(const QString &name);
    14. _File(const _File& file);
    15.  
    16. class FThread : public QThread{
    17. public:
    18. FThread();
    19. FThread(_File *par);
    20. virtual void run();
    21. FThread& operator=(const FThread& other);
    22. private:
    23. _File *parentFile;
    24.  
    25. };
    26. void setProgress(qint64 val);
    27. ...//goes on
    To copy to clipboard, switch view to plain text mode 

    and i am trying to create new instance of FThread in other file main.cpp

    fileObj->fthread=new _File::FThread(fileObj);

    and its giving me error as it doesn't recognize =new operator...it works fine if i dont add "new" keyword, but i need to create new instance in order to achieve my goal...

    i am getting following error

    ../engine/main.cpp:22: error: no match for ‘operator=’ in ‘fileObj->_File::fthread = (operator new(12u), (<statement>, ((_File::FThread*)<anonymous>)))’

    ../engine/_file.h:25: candidates are: _File::FThread& _File::FThread:perator=(const _File::FThread&)


    please help

    any help please?
    Last edited by high_flyer; 25th January 2011 at 21:26. Reason: code tags
    Life is like a dream, sometimes it is good and somtimes it is bad, but in the end it is over

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: operator=new ClassObj() is not recognized

    it looks like fileObj->fthread is a const - or probably not a pointer, but a value variable.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: operator=new ClassObj() is not recognized

    QThread is also a QObject so providing an assignment operator for it yields the same consequences as for QFile which I mentioned in another one of your threads. Based on how you are using this class I can tell you upfront there is no way you are going to use this assignment operator properly so you may as well remove it. Of course this has nothing to do with your current problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Swipe gesture not recognized
    By Luc4 in forum Qt Programming
    Replies: 2
    Last Post: 16th December 2014, 16:13
  2. Qmake command not recognized
    By Rakula in forum Installation and Deployment
    Replies: 2
    Last Post: 15th September 2014, 14:10
  3. Resize Policy not recognized
    By Ishmael in forum Newbie
    Replies: 1
    Last Post: 20th May 2010, 09:46
  4. mingw32-make not recognized
    By freekill in forum Installation and Deployment
    Replies: 4
    Last Post: 8th January 2010, 17:26
  5. slots and signals don't seem to be recognized
    By Jessehk in forum Qt Programming
    Replies: 2
    Last Post: 31st July 2007, 20:50

Tags for this Thread

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.