Results 1 to 8 of 8

Thread: blockingMap: no matching function for call to `(QList<QString>&, <unknown type>)`

  1. #1
    Join Date
    Aug 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default blockingMap: no matching function for call to `(QList<QString>&, <unknown type>)`

    Hi guys,

    I am trying to use the Thread functions like in the map example.

    I needed the scale function to access the ui, so I changed it in the cpp file to this:

    Qt Code:
    1. QString MainWindow::scale(const QString &filename)
    2. {
    3. ...
    4. }
    To copy to clipboard, switch view to plain text mode 

    This appearently required me to add it to the header file. I did it like this:
    Qt Code:
    1. ...
    2. public:
    3. MainWindow(QWidget *parent = 0);
    4. ~MainWindow();
    5. QString scale(const QString &filename);
    6. ...
    To copy to clipboard, switch view to plain text mode 

    The call remains
    Qt Code:
    1. QtConcurrent::blockingMapped(images, scale);
    To copy to clipboard, switch view to plain text mode 

    The error message I receive is:
    mainwindow.cpp:85: error: no matching function for call to `blockingMapped(QList<QString>&, <unknown type>)'
    Why doesn't he recognize the function anymore?

    Any help is greatly appreciated .

    qweide

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: blockingMap: no matching function for call to `(QList<QString>&, <unknown type>)`

    I think that your scale function either has to be declared outside the class, or be static.

  3. #3
    Join Date
    Aug 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: blockingMap: no matching function for call to `(QList<QString>&, <unknown type>)`

    Hi,

    Thanks for your ideas .
    I can't make it static in my opinion as I want to access the UI from there :/.
    I'll try to put it to a separate class, but I think that it would kill my access to the UI as well, wouldn't it?

    qweide

  4. #4
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: blockingMap: no matching function for call to `(QList<QString>&, <unknown type>)`

    Not a separate class, outside a class. Either way you can access it from other places. A static method does not have a "this" pointer, and when calling the function from QtConcurrent, without an object, there is no this pointer (think about it, it is obvious once you've wrapped your head around it... :-))

  5. #5
    Join Date
    Aug 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: blockingMap: no matching function for call to `(QList<QString>&, <unknown type>)`

    Hi,

    I don't really get what you mean .
    I attach my little project and would appreciate a lot if you had time to give it a quick look.

    Thanks in advance,
    qweide

    p.s. I come from the Java island .
    Attached Files Attached Files

  6. #6
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: blockingMap: no matching function for call to `(QList<QString>&, <unknown type>)`

    I have not looked at your project, but let me put it like this:

    What happens when you call something in QtConcurrent? The function that you pass to it is called repeatedly.

    How do you call scaled? You use an object instance, inst, and use the -> or . operator: inst->scale( ... ).

    The QtConcurrent framework does not have access to this. scale is simply a pointer to the scale function, not a specific class instance.

    Thus, scale cannot be an ordinary class function. It must be able to execute without a this pointer. By making scale static, you can call it either as MyClass::scale( ... ), or inst->scale( ... ). Which is good enough for QtConcurrent (and probably your needs as well).

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: blockingMap: no matching function for call to `(QList<QString>&, <unknown type>)`

    Quote Originally Posted by qweide View Post
    I can't make it static in my opinion as I want to access the UI from there :/.
    I'll try to put it to a separate class, but I think that it would kill my access to the UI as well, wouldn't it?
    You can't access the UI from threads anyway...
    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.


  8. #8
    Join Date
    Jul 2009
    Posts
    139
    Thanks
    13
    Thanked 59 Times in 52 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: blockingMap: no matching function for call to `(QList<QString>&, <unknown type>)`

    You can bind the this pointer to create a unary function object (a function object that takes one argument):
    Qt Code:
    1. #include <QtConcurrentMap>
    2. #include <functional>
    3.  
    4. QString MainWindow::scale(QString str)
    5. {
    6. qDebug() << str;
    7. return str;
    8. }
    9.  
    10.  
    11. MainWindow::MainWindow(QWidget *parent)
    12. : QMainWindow(parent)
    13. {
    14. QStringList images;
    15. images << "One" << "Two" << "Three";
    16.  
    17. QtConcurrent::blockingMapped(images, std::bind1st(std::mem_fun(&MainWindow::scale), this));
    18. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Regading Driver to connect Postgresql Database
    By dummystories in forum Installation and Deployment
    Replies: 38
    Last Post: 12th March 2009, 07:19
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.