0

I have a QMainWindow class.

class MainWindow: public QMainWindow
{
Q_OBJECT
    ...
public:
    void insertVector();
    ...
};

and I have class SqlStorage to make operation with Data Base.

class SqlStorage : public QObject {
Q_OBJECT
    ...
public:
    static void loadSQL();
    ...
};

In insertVector() method I try to asynchronously write in DB.

void MainWindow::insertVector()
{
    SqlStorage* _sqlStorage = new SqlStorage;
    QFuture<void> future = QtConcurrent::run(_sqlStorage, &SqlStorage::loadSQL);
}

But when I try to compile, I have error that: "term does not evaluate to a function taking 1 arguments".

Where is my problem?

koch_kir
  • 163
  • 17

1 Answers1

4

When you want to call static member functions with QtConcurrent::run, you do it the same way you call a regular non-member function. Only difference is you include the class scope in it. Like this:

QFuture<void> future = QtConcurrent::run(SqlStorage::loadSQL);
thuga
  • 12,601
  • 42
  • 52