LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-12-2008, 09:37 AM   #1
elprawn
Member
 
Registered: Feb 2005
Distribution: Gentoo 2008
Posts: 138

Rep: Reputation: 15
QFile and QProgressBar.


Okay, so I realise that I can't capture the bytesWritten() signal in order to show the file copy progress of the QFile.copy() function on a QProgressBar, but it's my understanding that this can be done using the QIODevice class, be it somewhat more complicated.

How might one go about achieving this in C++?

Thank you for you help.
 
Old 12-12-2008, 09:45 AM   #2
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by elprawn View Post
Okay, so I realise that I can't capture the bytesWritten() signal in order to show the file copy progress of the QFile.copy()
Why? o_O
Besides, what Qt version?
In Qt 4 - derive your own class from QProgressBar that has slot that accepts quint64. Or make temporary slot somewhere that can be linked to QFile's signal and will emit another signal for QProgressBar.
 
Old 12-12-2008, 09:56 AM   #3
elprawn
Member
 
Registered: Feb 2005
Distribution: Gentoo 2008
Posts: 138

Original Poster
Rep: Reputation: 15
Qt 4.

Quote:
Originally Posted by Online Documentation
Unlike other QIODevice implementations, such as QTcpSocket, QFile does not emit the aboutToClose(), bytesWritten(), or readyRead() signals. This implementation detail means that QFile is not suitable for reading and writing certain types of files, such as device files on Unix platforms.
And I should probably say at this stage I don't have much experience in programming in C++ but I understand in principle what you're saying about deriving a class that will allow me to access the signal.

Thanks once again.

Last edited by elprawn; 12-12-2008 at 09:58 AM.
 
Old 12-12-2008, 11:11 AM   #4
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by elprawn View Post
Qt 4.



And I should probably say at this stage I don't have much experience in programming in C++ but I understand in principle what you're saying about deriving a class that will allow me to access the signal.

Thanks once again.
Well, I thought it was emitting signal.

If it isn't emitting signal, then you can create your own copy routine (or class or whatever), that will emit required signal. You might even try to make your own QFile derivative that supports those signals, but that might be too difficult. If I were you I'd write class (based on Q_OBJECT, of course) for copying files, and made it emit signals you need.
 
  


Reply

Tags
bar, copy, file, progress


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a pointer to a QTextStream & QFile iwasapenguin Programming 5 04-21-2008 02:09 PM
Kded and Qfile::Open Murdock1979 Linux - Software 2 05-01-2006 03:40 PM
Geting error loop QFike:getch: File not open QFile:atEnd: this file is not open badgerbox76 Linux - Newbie 6 01-07-2006 05:30 PM
X11 complaining about QFile no file name Riddick Linux - Software 2 09-07-2005 12:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration