Results 1 to 3 of 3

Thread: QMutex QMutex::Recursive is not a type name

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QMutex QMutex::Recursive is not a type name

    Hi all !

    I have a class, which has a member

    Qt Code:
    1. QMutex mutex(QMutex::Recursive);
    To copy to clipboard, switch view to plain text mode 

    but the compiler says, that QMutex::Recursive is not a type name. But I need the Recursive Mode, cause the default Mode doesn't help me.
    QMutex is included.

    thx
    Last edited by high_flyer; 9th May 2011 at 11:46. Reason: code tags

  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: QMutex QMutex::Recursive is not a type name

    you can't initialize members with non default constructors like that in a header.
    Make your member a pointer, and then initialized it in the implementation file with the recursive mode.
    ==========================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. The following user says thank you to high_flyer for this useful post:

    Qiieha (9th May 2011)

  4. #3
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMutex QMutex::Recursive is not a type name

    Quote Originally Posted by high_flyer View Post
    you can't initialize members with non default constructors like that in a header.
    thank for your help...I solved the problem without using a pointer.
    header file
    Qt Code:
    1. class Test{
    2. private:
    3. QMutex mx;
    4. public:
    5. Test();
    6. }
    To copy to clipboard, switch view to plain text mode 

    cpp file
    Qt Code:
    1. Test::Test() :
    2. mx(QMutex::Recursive)
    3. {
    4. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QThread + QMutex example
    By eleanor in forum Qt Programming
    Replies: 2
    Last Post: 13th February 2010, 16:48
  2. QMutex seems not to lock()
    By sylvaticus in forum Qt Programming
    Replies: 18
    Last Post: 4th December 2009, 10:39
  3. QMutex
    By weixj2003ld in forum Qt Programming
    Replies: 6
    Last Post: 14th April 2009, 22:32
  4. New to QMutex
    By durbrak in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2009, 21:16
  5. QMutex and QDataStream
    By babu198649 in forum Newbie
    Replies: 15
    Last Post: 12th April 2008, 12:25

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
  •  
Qt is a trademark of The Qt Company.