Results 1 to 4 of 4

Thread: Display files one by one for particular directory - Just like antivirus scanning.

  1. #1
    Join Date
    Jul 2012
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Display files one by one for particular directory - Just like antivirus scanning.

    Hi! Experts

    I am making an application ....

    Using Browse button I select path of particular directory after clicking on the start button selected path shows in line edit and the files are shown in line edit one by one instead of list widget at one go. All the file names are displayed of that directory one by one after some duration.Displaying the files shoud be similar to anti-virus scanning software.

    My code for viewing in list widget is as follows...

    Qt Code:
    1. connect(browse,SIGNAL(clicked()),this,SLOT(find()));
    2.  
    3. void MainWindow::find()
    4. {
    5. QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),"/home",QFileDialog::ShowDirsOnly| QFileDialog::DontResolveSymlinks);
    6. QDir lsdir(dir);
    7. l->setText( dir );
    8. lw->addItems(lsdir.entryList());
    9. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Display files one by one for particular directory - Just like antivirus scanning.

    What do you mean "one by one"? Doesn't the code you posted do that already?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2012
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Display files one by one for particular directory - Just like antivirus scanning.

    mean of one by one is that second file must be shown after a one second of first file shown..

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Display files one by one for particular directory - Just like antivirus scanning.

    Quote Originally Posted by Gurpreet View Post
    mean of one by one is that second file must be shown after a one second of first file shown..
    Hmmm.... why?

    Qt Code:
    1. class InsertToListDelayer : public QObject {
    2. Q_OBJECT
    3. public:
    4. InsertToListDelayer(QStringList items, QListWidget *list, int delay = 1000, QObject *parent = 0) : QObject(parent) {
    5. m_items = items;
    6. m_list = list;
    7. m_delay = delay;
    8. m_timer = -1;
    9. }
    10. public slots:
    11. void start(int delay = -1) {
    12. if(delay > 0) m_delay = delay;
    13. m_timer = startTimer(m_delay);
    14. }
    15. void stop() {
    16. if(m_timer != -1) { killTimer(m_timer); m_timer = -1; }
    17. }
    18. signals:
    19. void finished();
    20. protected:
    21. void timerEvent(QTimerEvent *te) {
    22. m_list->addItem(m_items.takeFirst());
    23. if(m_items.isEmpty()) {
    24. stop();
    25. emit finished();
    26. }
    27. }
    28. private:
    29. int m_timer, m_delay;
    30. QStringList m_items;
    31. QListWidget* m_list;
    32. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. InsertToListDelayer *del = new InsertToListDelayer(lsdir.entryList(), lw, 1000, this);
    2. del->start();
    3. connect(del, SIGNAL(finished()), del, SLOT(deleteLater()));
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. List all XML files in a directory
    By ouekah in forum Newbie
    Replies: 4
    Last Post: 30th August 2015, 08:47
  2. display a directory using qtreewidget
    By kamlmish in forum Newbie
    Replies: 2
    Last Post: 19th December 2010, 12:37
  3. Replies: 1
    Last Post: 20th April 2010, 08:14
  4. Display files of a Directory
    By mansu in forum Qt Programming
    Replies: 2
    Last Post: 8th March 2009, 15:08
  5. directory and files
    By rmagro in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2008, 13:40

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.