Russian Qt Forum
Май 17, 2024, 22:58 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: QtConcurrent::run, непонятки  (Прочитано 6186 раз)
Sancho_s_rancho
Гость
« : Сентябрь 09, 2008, 13:55 »

Хочу считать файл в другом потоке, используя QImageReader

Код:
QImageReader imgReader;
 imgReader.setFileName("filename");
QImage *img = new QImage();
QFuture<QImage> future = QtConcurrent::run(imgReader, &QImageReader::read);
 *img = future.result();
получаю:
Цитировать
../Qt/4.4.1/include/QtGui/../../src/gui/image/qimagereader.h: In constructor `QtConcurrent::StoredMemberFunctionCall0<T, Class>::StoredMemberFunctionCall0(T (Class::*)(), const Class&) [with T = QImage, Class = QImageReader]':

../Qt/4.4.1/include/QtCore/../../src/corelib/concurrent/qtconcurrentrun.h:169:   instantiated from `QFuture<T> QtConcurrent::run(const Class&, T (Class::*)()) [with T = QImage, Class = QImageReader]'

image.cpp:53:   instantiated from here

../Qt/4.4.1/include/QtGui/../../src/gui/image/qimagereader.h:133: error: `QImageReader::QImageReader(const QImageReader&)' is private

../Qt/4.4.1/include/QtCore/../../src/corelib/concurrent/qtconcurrentstoredfunctioncall.h:120: error: within this context

mingw32-make[1]: *** [debug/image.o] Error 1
Что я делаю не так?
« Последнее редактирование: Сентябрь 09, 2008, 14:50 от Sancho_s_rancho » Записан
Sancho_s_rancho
Гость
« Ответ #1 : Сентябрь 11, 2008, 09:17 »

Видимо такая бяка происходит при вызове из конструктора.
Записан
denka
Гость
« Ответ #2 : Сентябрь 11, 2008, 09:52 »

Видимо такая бяка происходит при вызове из конструктора.
Видимо читать асистент внимательно надо Подмигивающий.
Цитировать
QFuture<T> QtConcurrent::run ( Function function, ... )
Runs function in a separate thread. The thread is taken from the global QThreadPool. Note that the function may not run immediately; the function will only be run when a thread is available.

T is the same type as the return value of function. Non-void return values can be accessed via the QFuture::result() function.

Note that the QFuture returned by QtConcurrent::run() does not support canceling, pausing, or progress reporting. The QFuture returned can only be used to query for the running/finished status and the return value of the function.
Записан
Sancho_s_rancho
Гость
« Ответ #3 : Сентябрь 11, 2008, 12:58 »

Видимо такая бяка происходит при вызове из конструктора.
Видимо читать асистент внимательно надо Подмигивающий.
Цитировать
QFuture<T> QtConcurrent::run ( Function function, ... )
Runs function in a separate thread. The thread is taken from the global QThreadPool. Note that the function may not run immediately; the function will only be run when a thread is available.

T is the same type as the return value of function. Non-void return values can be accessed via the QFuture::result() function.

Note that the QFuture returned by QtConcurrent::run() does not support canceling, pausing, or progress reporting. The QFuture returned can only be used to query for the running/finished status and the return value of the function.

Простите, это вы к чему?
Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.055 секунд. Запросов: 21.