Results 1 to 5 of 5

Thread: Doubts about QtConcurrent::run and members functions

  1. #1
    Join Date
    Jul 2007
    Location
    Jundiai/SP, Brazil
    Posts
    114
    Thanks
    5
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Doubts about QtConcurrent::run and members functions

    Hi All, Happy new year!

    I've tried to use QtConcurrent::run with members functions, but I have not had success.
    Then I resolved to quiz this example of documentation:

    Qt Code:
    1. QString string = "red,blue,green";
    2. QFuture<QStringList> future = QtConcurrent::run(string, &QString::split, QString(", "), QString::KeepEmptyParts, Qt::CaseSensitive);
    3. QStringList result = future.result();
    To copy to clipboard, switch view to plain text mode 

    But the following error of compilation occurs

    qreport.cpp: In constructor 'qreport::qreport()':
    qreport.cpp:57: error: no matching function for call to 'run(QString&, <unresolved overloaded function type>, QString, QString::SplitBehavior, Qt::CaseSenitive);

    What is happening?

    Thanks in advance.

  2. #2
    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: Doubts about QtConcurrent::run and members functions

    I think is should be "QString::split" and not "&QString:split".
    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.


  3. #3
    Join Date
    Jul 2007
    Location
    Jundiai/SP, Brazil
    Posts
    114
    Thanks
    5
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Doubts about QtConcurrent::run and members functions

    Hi wysota,

    Not, unfortunately it is not this the problem.
    By the way this topic is really an a lot confused one.
    You've some piece of code that use functions member in threads?
    It is very difficult find some explanation about this matter.

    Thanks a lot.

  4. #4
    Join Date
    Mar 2006
    Posts
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Doubts about QtConcurrent::run and members functions

    Qt Code:
    1. QString string = "red,blue,green";
    2. typedef QStringList (QString::*splitFunction)(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const;
    3. splitFunction function = &QString::split;
    4. QFuture<QStringList> future = QtConcurrent::run(string, function, QString(","), QString::KeepEmptyParts, Qt::CaseSensitive);
    5. future.waitForFinished();
    6. QStringList sl = future.result();
    7. qDebug() << sl.join(" -- ");
    To copy to clipboard, switch view to plain text mode 

    I think it happens because QString split function is overloaded and compiler cannot determine which function is right to use in template. But I could be wrong.

  5. The following 2 users say thank you to Rembobo for this useful post:

    numbat (15th January 2010), vcp (14th January 2010)

  6. #5
    Join Date
    Jul 2007
    Location
    Jundiai/SP, Brazil
    Posts
    114
    Thanks
    5
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Doubts about QtConcurrent::run and members functions

    Thanks Rembobo,

    I think that you are not wrong, but the example of the documentation of the Qt is. Or bad formulated.
    His explanation does very sense for me.

Similar Threads

  1. Yet another bunch of doubts!
    By Nishant in forum Newbie
    Replies: 2
    Last Post: 23rd December 2009, 15:49
  2. doubts regarding QT
    By sudheer168 in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2009, 09:02
  3. some doubts qtablewidget
    By mmm286 in forum Qt Programming
    Replies: 1
    Last Post: 2nd August 2009, 20:36
  4. Static functions and class members
    By Raistlin in forum General Programming
    Replies: 5
    Last Post: 22nd December 2006, 10:00
  5. Basic C++ doubts
    By munna in forum General Programming
    Replies: 3
    Last Post: 6th April 2006, 16:23

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.