Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2304

QObject::runInBackgroundThread

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • P3: Somewhat important
    • Some future release
    • None
    • Core: Threads
    • None

    Description

      Simple, non-template QObject member functions, available on all platforms:

      runInBackgroundThread(const char * slot, ... args);
      runInObjectThread(const char * slot, ... args);
      cancelAll();

      • Monitors the event loop queue and ajusts the number of threads to prevent overloading the ObjectThread.
      • Blocks until all tasks have finised when the object is deleted.

      Example:
      void ImageViewer::loadFiles(const QStringList &files)
      {
      foreach (QString &file, files)
      runInBackgroundThread("decodeFile", Q_ARG(QString, file));
      }

      QImage ImageViewer::decodeFile(const QString &fileName)
      {
      QImage image(fileName);
      runInObjectThread("addImage", Q_ARG(QImage, image));
      }

      void ImageViewer::addImage(const QImage &image)
      {
      layout()->addWidget(new QLabel(image));
      update();
      }

      Distributed programming add-on
      runInDistributedThread(const char * slot, ... args);

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sorvig Morten Sørvig
            sorvig Morten Sørvig
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes