QtConcurrent::map Сan't use QVector from class

  • Hi.
    In the file main.cpp I need start void StrategyCod1(double) in 4 thread:

    void StrategyCod1(double Parametr)
        QMutex Mutex;
        MainWindow w;
        QVector<double> Open=w.Open;
        int NMA=Parametr;
    int main(int argc, char *argv[])
        QApplication a(argc, argv);
        MainWindow w;   
        QVector<double> Perebor; //перебор первого значения стратегии
        for (double i=5;i<1000;i=i+3)
        QFuture<void> Perebor2 = QtConcurrent::map(Perebor, StrategyCod1);
        return a.exec();

    But when I run the program stops. Error in call MainWindow w.
    How do I use QVector from class MainWindow?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What exactly do you want to achieve ?

    In any case, your MainWindow variable in StrategyCod1 is local and will be destroyed at the end of the function.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.