Results 1 to 4 of 4

Thread: use QDialog to show file name

  1. #1
    Join Date
    Oct 2008
    Location
    Taiwan
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default use QDialog to show file name

    Dear All:
    I subclass QDialog which includes a QLabel and a QProgressBar.
    QLabel is about to show deleting file name and QProgreeBar is for progress.
    But Dialog seems to busy if you call QLabel ::setText(),
    it'll ok if you call QProgreeBar::setValue();

    I doubt "model()->filename(iIdx).filePath()" takes more execution time ...

    I use recursive to implement deleting function, for example

    int file_recursive_delete(QModelIndex iIdx)
    {
    // it'll call QLabel ::setText(), but Dialog won't update text until deleting is finished
    emit notifyFileNameToProgress( model()->filename(iIdx).fileName() );

    // it'll call QProgreeBar::setValue(), and it works....Dialog won't busy....
    emit notifyValueToProgress();

    // ...... do deleting
    }

  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: use QDialog to show file name

    First of all take a look at QProgressDialog. Second of all, if you want the progress bar to redraw itself after you update its value, you have to let your application process its events, for instance by calling sendPostedEvents() or QCoreApplication::processEvents().

  3. #3
    Join Date
    Oct 2008
    Location
    Taiwan
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use QDialog to show file name

    Thank you so much .....
    I add processEvents() in the subclass and worked correctly
    I wonder why I have to add processEvents().
    Is it because the UI is too busy to process the slot ??

  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: use QDialog to show file name

    Qt only processes events when the control returns to the event loop. When you are inside any function you write yourself (like a slot or event handler) the control is not in the event loop but in your function, hence other events are not processed. Qt doesn't use external threads to process events, so there is no magical way of having the events processed other than to request it yourself, for example with processEvents(). If you are a commercial Qt user, you can read an article about it in the latest (#27) Qt Quarterly.

Similar Threads

  1. qdirmodel question: show file number of a folder?
    By zl2k in forum Qt Programming
    Replies: 3
    Last Post: 7th November 2008, 07:07
  2. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  3. Display a file from Directory tree to show in QTextEdit
    By vvdounai in forum Qt Programming
    Replies: 1
    Last Post: 13th November 2007, 13:43
  4. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  5. QDialog: show() and exec() together in constructor?
    By Teuniz in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2007, 11:43

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.