When your main-thread stalls you did not create a new thread/did not start it. I suggest rerading the Documentation about QThread carefully.
The only way to resize without setting bytes to 0 is to not use Qt here.
When your main-thread stalls you did not create a new thread/did not start it. I suggest rerading the Documentation about QThread carefully.
The only way to resize without setting bytes to 0 is to not use Qt here.
Hi Christian,
thanks for answering
Qt Code:
MyMain::MyMain() { ... fileThread= new MyFileThread(this); fileThread->start(); } void MyFileThread::run() { exec(); }To copy to clipboard, switch view to plain text mode
the fileThread->isRunning() returns true, and the QTimer in fileThread starting the resize, works too.
I'm almost going to rewrite the QFile::resize with inserted qApp->processEvent() (don't know yet if it would be secure enough)
That sounds good, but could you please help me here, because I couldn't find an example how to do it, everywhere I looked, it is initialized with some value. (any link or code snippet would be highly appreciated)The only way to resize without setting bytes to 0 is to not use Qt here.
Thanks
Looks fine - and where do you do the actual resize?
A WInAPI function to use is SetFilePointer() but you should remember that it's winapi and not protable. Also winapi isn't that easy for beginners.
Qt Code:
{ connect(timer, SIGNAL(timeout()), this, SLOT(save())); timer->start(60000); } void MyFileThread::save() { timer->stop(); resizeSuccess = file.resize(data->files_info->size); }To copy to clipboard, switch view to plain text mode
I just tried it again (with fileThread= new MyFileThread()<-without the parent);, and it still stalls the gui until it's done resizing.
I have never used winapi so it would be a new realm ..sigh..A WInAPI function to use is SetFilePointer() but you should remember that it's winapi and not protable. Also winapi isn't that easy for beginners.but I will look it up
I've read there is also a possibility doing something similar in the ext3-linux filesystem
(but it will be primarily for win-xp)
thanks
You use QThread wrong. The connect is done in the main thread and since it's a direct connection, the resize will also be done in the main thread and therefore the GUI is stalled.
Okay, so I have to put the connect here?
Qt Code:
void MyFileThread::run() { connect(timer, SIGNAL(timeout()), this, SLOT(save())); timer->start(60000); }To copy to clipboard, switch view to plain text mode
that doesn't work either - I have no clue..sigh..
This should work - now QTimer is also in the thread. Plz also ready Qt::ConnectionType Documentation.
btw: Why not use QTimer::singleShot() ?
MaximA (27th May 2008)
Thanks, I have some serious reading and recoding to do ('cause it's still not working)
(Threads aren't trivial)
the timer will later be used repeatedly for different files
I come back later, after some "homework"
Have a nice day.
Bookmarks