×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    7

    QFileWatcher problem

    Hello,

    I am new to QT programming. I am using QFileWatcher in my application and it working fine, but problem is I am getting notifications for all the files and directories including Hidden files and directoris. Is there any way to avoid notifications for hidden files in the phone...?

    please can any one help me .....


    regards,
    Manju

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QFileWatcher problem

    Quote Originally Posted by manjunath369 View Post
    Hello,

    I am new to QT programming. I am using QFileWatcher in my application and it working fine, but problem is I am getting notifications for all the files and directories including Hidden files and directoris. Is there any way to avoid notifications for hidden files in the phone...?

    please can any one help me .....


    regards,
    Manju
    Do you mean QFileSystemWatcher? To avoid actions on hidden files in the slot attached to fileChanged signal
    you can use the following code:
    Code:
    QFileInfo info(fileName);
    if (info.isHidden())
        return;

  3. #3
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: QFileWatcher problem

    Is't it so that fileChanged is triggered only for files I am expressly monitoring? Which means if the file is hidden I should not have it added to the watcher to begin with.

    So is this really about avoiding fileChanged or directoryChanged signals for such files?
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  4. #4
    Registered User
    Join Date
    Dec 2009
    Posts
    39

    Re: QFileWatcher problem

    Quote Originally Posted by ltomuta View Post
    Is't it so that fileChanged is triggered only for files I am expressly monitoring?
    If you give a directoy as the path to watch, the QFileSystemWatcher monitors all files in that directory and it's subdirectories. The alternative is to add single files as the watched path.

    Quote Originally Posted by ltomuta View Post
    Which means if the file is hidden I should not have it added to the watcher to begin with.

    So is this really about avoiding fileChanged or directoryChanged signals for such files?
    Well, the alternative then would be to iterate over all the files in a directory and it's subdirectories and only add the visible files.

    I would have thought that it's simpler, though arguably wasteful, to add the whole directory and filter out the hidden files on directoryChanged, like Divanov suggested.

  5. #5
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QFileWatcher problem

    Quote Originally Posted by lsvensson View Post
    I would have thought that it's simpler, though arguably wasteful, to add the whole directory and filter out the hidden files on directoryChanged, like Divanov suggested.
    It depends on number of files and sub-directories and purpose of the monitoring. It's not good to add thousands of watches as well. For example, on Linux you cannot have more than 128 watchers per user with max 8192 instances per watcher (by default).

  6. #6
    Registered User
    Join Date
    Jan 2010
    Posts
    7

    Re: QFileWatcher problem

    Hi all,

    actually i need to watch all the drives in a phone. whenever any changes occur in a file system, i need to get a notification with corresponding file or directory path.

    is it possible in QT...?

    thanks and regards,
    Manju

  7. #7
    Registered User
    Join Date
    Dec 2009
    Posts
    39

    Re: QFileWatcher problem

    In theory it's possible, just add the root folder path of each drive to your QFileSystemWatcher. However, as divanov mentioned above, the number of files you can monitor in practice may be limited by the system resources.

    I can't find anything specific to Symbian about an upper limit of watchers or monitored files, but the Qt documentation mentions that "Some system limits the number of open file descriptors to 256 by default".

    Does anyone know of any specifics for Symbian?

  8. #8
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QFileWatcher problem

    Quote Originally Posted by lsvensson View Post
    In theory it's possible, just add the root folder path of each drive to your QFileSystemWatcher. However, as divanov mentioned above, the number of files you can monitor in practice may be limited by the system resources.
    No, you can add one watch to the root folder. The only one watch with several paths is not a problem.

  9. #9
    Registered User
    Join Date
    Dec 2009
    Posts
    39

    Re: QFileWatcher problem

    Quote Originally Posted by divanov View Post
    The only one watch with several paths is not a problem.
    Yes, but there may still be a limit to how many files/paths a single watcher can keep track of. Or is that a misunderstanding on my side?

  10. #10
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QFileWatcher problem

    Quote Originally Posted by lsvensson View Post
    Yes, but there may still be a limit to how many files/paths a single watcher can keep track of. Or is that a misunderstanding on my side?
    Yes, but you have only several disks normally, i.e. ~5 paths only.

  11. #11
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: QFileWatcher problem

    That depending on what you call "system file". I wouldn't set a watcher on a path like "c:" and then scan the entire file system for a change when directoryChange is signaled.

    I think the question for manjunath369 is really what does he want to do? If his interest would be to write an antivirus application for example then surely Qt is not the way to go.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

Similar Threads

  1. STLPort namespace issue
    By yickhong in forum Open C/C++
    Replies: 0
    Last Post: 2009-04-09, 08:54
  2. SyncML link problem
    By samuel_ in forum Symbian
    Replies: 4
    Last Post: 2009-03-27, 08:02
  3. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  4. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  5. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×