Results 1 to 2 of 2

Thread: Qt 5 class parameter as std::function<>

  1. #1
    Join Date
    Jun 2007
    Location
    Louisiana
    Posts
    77
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Qt 5 class parameter as std::function<>

    I am having difficulty with some borrowed code that is supposedly working. It contains a class defined like:

    Qt Code:
    1. #include <functional>
    2. using namespace std;
    3.  
    4. class ClassName
    5. {
    6. public:
    7. ClassName(parm1 parm, const std::function<double(quint16,quint16)>& func, parm3 param);
    8. };
    To copy to clipboard, switch view to plain text mode 

    The Qt 5.5 compiler complains:
    function does not name a type
    and of course, a few errors that cascade after due to this one.

    I am not sure what the compiler error is all about. The library <functional> is where the function<> is contained and is included.

    What am I missing here?

  2. #2
    Join Date
    Nov 2015
    Posts
    41
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt 5 class parameter as std::function<>

    I can compile without any problem this

    Qt Code:
    1. class ClassName
    2. {
    3. public:
    4. ClassName(int x, const std::function<double(quint16,quint16)>& func, int y, int z);
    5. };
    To copy to clipboard, switch view to plain text mode 

    and inside .pro file I have line

    Qt Code:
    1. CONFIG += C++14
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to Scope for this useful post:

    ad5xj (3rd December 2015)

Similar Threads

  1. Replies: 3
    Last Post: 12th November 2014, 08:38
  2. Replies: 14
    Last Post: 1st December 2009, 20:45
  3. Replies: 3
    Last Post: 17th July 2008, 07:43
  4. skip function parameter
    By mattia in forum General Programming
    Replies: 4
    Last Post: 22nd November 2007, 15:55
  5. const function parameter problems
    By stevey in forum General Programming
    Replies: 3
    Last Post: 18th December 2006, 22:22

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.