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. I Need Some Help With QtConcurrent On Mac

I Need Some Help With QtConcurrent On Mac

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 4 Posters 1.3k Views
  • 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.
  • Christian EhrlicherC Christian Ehrlicher

    @TheCRV Of what type is m_prepareForChecksum01 and treeChecksum01/browseChecksum01?

    T Offline
    T Offline
    TheCRV
    wrote on last edited by
    #7

    @Christian-Ehrlicher m_prepareForChecksum01 is a QFuture<Void>, and treeChecksum01 and browseChecksum01 are local member functions to MainWindow.

    Christian EhrlicherC 1 Reply Last reply
    0
    • T TheCRV

      @Christian-Ehrlicher m_prepareForChecksum01 is a QFuture<Void>, and treeChecksum01 and browseChecksum01 are local member functions to MainWindow.

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #8

      @TheCRV said in I Need Some Help With QtConcurrent On Mac:

      d treeChecksum01 and browseChecksum01 are local member functions to MainWindow.

      And what's the signature of those functions?
      Please provide a minimal, compilable example so we can take a look on it - shouldn't be that hard here.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      T 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @TheCRV said in I Need Some Help With QtConcurrent On Mac:

        d treeChecksum01 and browseChecksum01 are local member functions to MainWindow.

        And what's the signature of those functions?
        Please provide a minimal, compilable example so we can take a look on it - shouldn't be that hard here.

        T Offline
        T Offline
        TheCRV
        wrote on last edited by
        #9

        @Christian-Ehrlicher Thanks for your help. The signature of those functions are void and they take no parameters. I think that a minimally compilable example might be too much for here, so you can take a look at everything at: https://github.com/TheCRV/Checksum1-V1.0/tree/master

        Again, I thank everyone for their help.

        Christian EhrlicherC 1 Reply Last reply
        0
        • T TheCRV

          @Christian-Ehrlicher Thanks for your help. The signature of those functions are void and they take no parameters. I think that a minimally compilable example might be too much for here, so you can take a look at everything at: https://github.com/TheCRV/Checksum1-V1.0/tree/master

          Again, I thank everyone for their help.

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #10

          @TheCRV Sorry but your code does not match what you've shown here. I don't see why it should be so hard to create a minimal class with a function and a QFuture member so we can check it.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          T 2 Replies Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            @TheCRV Sorry but your code does not match what you've shown here. I don't see why it should be so hard to create a minimal class with a function and a QFuture member so we can check it.

            T Offline
            T Offline
            TheCRV
            wrote on last edited by TheCRV
            #11

            @Christian-Ehrlicher Okay, here is some code that gives me the same error:

            My mainwindow.h file:

            #ifndef MAINWINDOW_H
            #define MAINWINDOW_H
            
            #include <QMainWindow>
            #include <QtConcurrent>
            #include <QFuture>
            #include <QDebug>
            
            QT_BEGIN_NAMESPACE
            namespace Ui {
            class MainWindow;
            }
            QT_END_NAMESPACE
            
            class MainWindow : public QMainWindow
            {
                Q_OBJECT
            
            public:
                MainWindow(QWidget *parent = nullptr);
                ~MainWindow();
            
            private:
                Ui::MainWindow *ui;
                QVector<int> numbers;
                QFuture<void> future;
            
                void addNumbers1();
                void addNumbers2();
            };
            #endif // MAINWINDOW_H
            

            My mainwindow.cpp file:

            #include "mainwindow.h"
            #include "ui_mainwindow.h"
            
            MainWindow::MainWindow(QWidget *parent)
                : QMainWindow(parent)
                , ui(new Ui::MainWindow)
            {
                ui->setupUi(this);
                addNumbers1();
            }
            
            MainWindow::~MainWindow()
            {
                delete ui;
            }
            
            
            void MainWindow::addNumbers1()
            {
                future = QtConcurrent::map(this, &MainWindow::addNumbers2);
            }
            
            
            void MainWindow::addNumbers2()
            {
                for(int i = 0; i < 1000; ++i)
                {
                    numbers.append(i);
                    qDebug() << i;
                }
            }
            
            

            My main.cpp file:

            #include "mainwindow.h"
            
            #include <QApplication>
            #include <QLocale>
            #include <QTranslator>
            
            int main(int argc, char *argv[])
            {
                QApplication a(argc, argv);
            
                QTranslator translator;
                const QStringList uiLanguages = QLocale::system().uiLanguages();
                for (const QString &locale : uiLanguages) {
                    const QString baseName = "Test_" + QLocale(locale).name();
                    if (translator.load(":/i18n/" + baseName)) {
                        a.installTranslator(&translator);
                        break;
                    }
                }
                MainWindow w;
                w.show();
                return a.exec();
            }
            

            Thanks again for any help. I'm pretty sure my problem has something to do with Qt 6, as with Qt 5.x I never had any trouble on Windows.

            I would be perfectly happy if I could get QtConcurrent::run to work.

            1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              @TheCRV Sorry but your code does not match what you've shown here. I don't see why it should be so hard to create a minimal class with a function and a QFuture member so we can check it.

              T Offline
              T Offline
              TheCRV
              wrote on last edited by
              #12

              @Christian-Ehrlicher Okay, I have gotten QtConcurrent::run to work by changing my test code to this:

              future = QtConcurrent::run(&MainWindow::addNumbers2, this);
              

              I am still curious why map didn't work, but we can consider this solved. Thanks again.

              JonBJ 1 Reply Last reply
              0
              • T TheCRV

                @Christian-Ehrlicher Okay, I have gotten QtConcurrent::run to work by changing my test code to this:

                future = QtConcurrent::run(&MainWindow::addNumbers2, this);
                

                I am still curious why map didn't work, but we can consider this solved. Thanks again.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #13

                @TheCRV
                From https://doc.qt.io/qt-6/qtconcurrent.html#map I was wondering which overload you were intending to match in your QtConcurrent::map(this, &MainWindow::addNumbers2)? That page is for Qt6, must be some map() overload was removed from Qt5 which matched yours?

                You said initially it was a Mac issue that worked on Windows. But now I think you are saying that was Qt5 and now is Qt6? Needs mentioning!

                Christian EhrlicherC 1 Reply Last reply
                0
                • JonBJ JonB

                  @TheCRV
                  From https://doc.qt.io/qt-6/qtconcurrent.html#map I was wondering which overload you were intending to match in your QtConcurrent::map(this, &MainWindow::addNumbers2)? That page is for Qt6, must be some map() overload was removed from Qt5 which matched yours?

                  You said initially it was a Mac issue that worked on Windows. But now I think you are saying that was Qt5 and now is Qt6? Needs mentioning!

                  Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by Christian Ehrlicher
                  #14

                  I really wonder whats so hard to provide a minimal example... for sure it's important for the problem to load a translator and init an ui... simply not understandable.

                  Your code does and can not compile with msvc and Qt6 ueither because there is no QtConcurrent::map() which takes those parameters.

                  class Foo : public QObject {
                  public:
                      Foo() {
                          future = QtConcurrent::map(this, &Foo::addNumbers1);
                      }
                  private:
                      QFuture<void> future;
                      void addNumbers1() {}
                  };
                  
                  int main(int argc, char* argv[]) {
                      QApplication a(argc, argv);
                      Foo foo;
                      return a.exec();
                  }
                  

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  T 1 Reply Last reply
                  1
                  • Christian EhrlicherC Christian Ehrlicher

                    I really wonder whats so hard to provide a minimal example... for sure it's important for the problem to load a translator and init an ui... simply not understandable.

                    Your code does and can not compile with msvc and Qt6 ueither because there is no QtConcurrent::map() which takes those parameters.

                    class Foo : public QObject {
                    public:
                        Foo() {
                            future = QtConcurrent::map(this, &Foo::addNumbers1);
                        }
                    private:
                        QFuture<void> future;
                        void addNumbers1() {}
                    };
                    
                    int main(int argc, char* argv[]) {
                        QApplication a(argc, argv);
                        Foo foo;
                        return a.exec();
                    }
                    
                    T Offline
                    T Offline
                    TheCRV
                    wrote on last edited by
                    #15

                    @Christian-Ehrlicher I do apologize for not providing a minimal-enough example. You have showed me how to do so. Thanks again.

                    Christian EhrlicherC 1 Reply Last reply
                    0
                    • T TheCRV has marked this topic as solved on
                    • T TheCRV

                      @Christian-Ehrlicher I do apologize for not providing a minimal-enough example. You have showed me how to do so. Thanks again.

                      Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #16

                      It's not about showing - it's about thinking on how to provide the needed information instead simply copying something together and hope that the others fiddle out what the real problem is. Esp. since this helps to find out the real problem by yourself.

                      So did you solve your problem now?

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      T 1 Reply Last reply
                      0
                      • Christian EhrlicherC Christian Ehrlicher

                        It's not about showing - it's about thinking on how to provide the needed information instead simply copying something together and hope that the others fiddle out what the real problem is. Esp. since this helps to find out the real problem by yourself.

                        So did you solve your problem now?

                        T Offline
                        T Offline
                        TheCRV
                        wrote on last edited by
                        #17

                        @Christian-Ehrlicher Yes, my problem is solved. I'm having another problem with including openSSL in my app. I will open another post for this.

                        1 Reply Last reply
                        0

                        • Login

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