Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtConcurrent::map Сan't use QVector from class
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 536 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mikee
    wrote on last edited by
    #1

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

    void StrategyCod1(double Parametr)
    { 
        QMutex Mutex;
        Mutex.lock();
        MainWindow w;
        QVector<double> Open=w.Open;
        Mutex.unlock();
        int NMA=Parametr;
        qDebug()<<NMA;
    }
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;   
        QVector<double> Perebor; //перебор первого значения стратегии
        for (double i=5;i<1000;i=i+3)
        {
            Perebor.append(i);
        }
        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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved