Results 1 to 3 of 3

Thread: Updating MainWindow from slot

  1. #1
    Join Date
    Feb 2009
    Posts
    21
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Updating MainWindow from slot

    Hi,

    I have the following slot -

    Qt Code:
    1. QObject::connect(ui.addCasePushButton, SIGNAL(clicked ()), this, SLOT(browseToCaseFile()));
    2.  
    3. void SelectCaseWindow::browseToCaseFile()
    4. {
    5. QString fileName = QFileDialog::getOpenFileName(this, tr("Browse to Case File"), "/home/", tr("Case Files (*.cas)"));
    6.  
    7. repaint();
    8.  
    9. // if a file is selected
    10. if(!fileName.isEmpty())
    11. localCaseList->addLocally(QDir(fileName));
    12. }
    To copy to clipboard, switch view to plain text mode 

    The problem is that addLocally takes about 20 seconds to process. As a result, there is a grey patch over the SelectCaseWindow where the file dialog was, which disappears after the slot function completes. What can I do to update this region of the screen before I call addLocally? The repaint doesn't seem to do anything.

    I'm working on Ubuntu 9.04.

    Thanks,

    Barry.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Updating MainWindow from slot

    Try to call
    Qt Code:
    1. qApp->processEvents()
    To copy to clipboard, switch view to plain text mode 
    before you call addLocally. You may also have a look at QApplication::setOverrideCursor().

  3. The following user says thank you to Lykurg for this useful post:

    Barry79 (11th May 2009)

  4. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Updating MainWindow from slot

    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. Replies: 9
    Last Post: 13th August 2008, 18:07
  2. Problem When Creating my own Slot
    By Fatla in forum Qt Programming
    Replies: 12
    Last Post: 6th June 2008, 14:44
  3. Notifying Mainwindow of an event..
    By MrGarbage in forum Qt Programming
    Replies: 1
    Last Post: 9th November 2007, 21:29
  4. Replies: 1
    Last Post: 11th September 2007, 13:34

Tags for this Thread

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.