Results 1 to 5 of 5

Thread: Qfilesystemwatcher filechanged() signal not triggering

  1. #1
    Join Date
    Oct 2017
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Qfilesystemwatcher filechanged() signal not triggering

    Hi All,
    I am trying to use qfilesystemwatcher on a touch input file to detect touch idleness for a specific amount of time, And turn Display back light off/on accordingly. But I don't see the signal being triggered, when the file changed. The touch file I am monitoring is "/dev/input/event0" which is event file assocaited with my touch driver. When I check using cat command I could see this file being changed on each touch I do, But not working in my code using qfilesystemwatcher. Can you please look at my code and see, If I am missing anything?

    Qt Code:
    1. QFileSystemWatcher *touchFileWatcher;
    2. QStringList *watchPaths = new QStringList(Inputfile);
    3. touchFileWatcher = new QFileSystemWatcher(*watchPaths,parent);
    4. qDebug() << "touchFileWatcher Files: " << touchFileWatcher->files();
    5. connect(touchFileWatcher,SIGNAL(fileChanged(const QString &)),this,SLOT(touchFileChanged(const QString &)));
    6.  
    7. void Hardware::touchFileChanged(const QString &path)
    8. {
    9. qDebug() << "File changed" << path;
    10. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2018
    Location
    Bangalore, India
    Posts
    6
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qfilesystemwatcher filechanged() signal not triggering

    Try giving only QString as an argument and also for passing any parameters to a slot you need to use QSignalMapper.
    Here : QSignalMapper
    Qt Code:
    1. QSignalMapper* map1= new QSignalMapper (this) ;
    2. connect (any_action, SIGNAL(triggered()), map1, SLOT(map())) ;
    3. map1-> setMapping (any_action, 1) ;//one is argument being passed
    4. connect (map1, SIGNAL(mapped(int)), this, SLOT(onStepIncreased(int))) ;
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2017
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Qfilesystemwatcher filechanged() signal not triggering

    Hi Yashwanth,
    I tried both signal mapper method as well as giving only Qstring as argument. But None of these options helped, I couldn't see the event being triggered.

    Any More help?

    Thanks,
    Nagendra.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,386
    Thanks
    247
    Thanked 687 Times in 677 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Qfilesystemwatcher filechanged() signal not triggering

    A device driver entry in the linux file system is not like an ordinary file, so it is possible that QFileSystemWatcher does not work for these. Try an experiment - have it look at an ordinary text file, edit the file, save it, and see if you get a signal.

    It's also possible that Qt's input handlers for keyboard, mouse, and touch are already handling this, so QFileSystemWatcher is ignoring the file. Can't you use a handler for QTouchEvent to accomplish what you want instead of trying to watch the file?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Oct 2017
    Posts
    16
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Qfilesystemwatcher filechanged() signal not triggering

    Hi @d_stranz,
    Thanks for your reply. Yes you are correct. QFileSystemWatcher isn't working for driver entry file. On normal text file it's working fine. I tried using QTouchInput, But it didn't work as expected.
    So to solve this, I did override notify(QObject *sender,QEvent *event) method of QApplication and able to put this function as entry for all inputs. Once I do the processing, I am forwarding it to corresponding widget.

    Thanks,
    Nagendra

Similar Threads

  1. Replies: 2
    Last Post: 9th May 2017, 07:52
  2. Triggering the completer codewise
    By Sytse in forum Qt Programming
    Replies: 0
    Last Post: 2nd March 2016, 13:43
  3. QFileSystemWatcher no fileChanged signal
    By Talei in forum Newbie
    Replies: 6
    Last Post: 18th December 2011, 11:05
  4. QFilesystemWatcher fileChanged events
    By rhblind in forum Newbie
    Replies: 0
    Last Post: 17th August 2011, 10:19
  5. QFileSystemWatcher fileChanged signal doubling
    By roxton in forum Qt Programming
    Replies: 6
    Last Post: 16th May 2008, 13:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.