Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to update status bar during lengthy computations
Forum Updated to NodeBB v4.3 + New Features

How to update status bar during lengthy computations

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    In my desktop application I would like to update text in a status bar during lengthy computations. I do know about Progress Bar, but my needs are different. I also read "the applicable article":http://doc.qt.digia.com/qq/qq27-responsive-guis.html and came up with simple code:

    @void mainwindow::setStatusText(QString text) {
    statusBar()->showMessage(text);
    QCoreApplication::sendPostedEvents(statusBar(),0);
    QCoreApplication::flush();
    QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
    }@

    However I observe that even though I do both sending and flushing not all status text setting are coming through, some are delayed. For example if there are 4 consecutive calls to my setStatusText and I am stopped in the debugger after all four but before returning to main event loop, then actually displayed text (on Mac OS X) shows only results of the 2nd call but not the 4th. This happens regardless on the order in which I invoke sendPostedEvents & flush.

    Any ideas how I can fix it?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      How do you call setText()?
      Do you execute the long operation in a separate thread?

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        setStatusText() is being called from main execution thread, not from a separate thread.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jyang772
          wrote on last edited by
          #4

          Take a look at the last post.
          http://qt-project.org/forums/viewthread/43092/

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            I think complexities of asynchronous worker threads are not justified in my case and am looking for a simple solution. I don't need to have other aspects of GUI responsive. App window is already movable and I don't want user to be able to interact with GUI controls. I want to only refresh displayed text.

            By the way, doing flush() after processEvents() does not help either.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved