Qt World Summit: Submit your Presentation

QScrollBar values changes when a modeless dialog is created

  • In my application, I am creating a QListWidget with customized QScrollBar. If I select a list item, then I have made a modeless dialog box (to display msgs like "Processing.....") before loading another GUI screen.

    To make the modeless dialog visible immediately, QCoreApplication::processEvents() is called.
    When this line gets executed, my modeless dialog starts visible and my scrollbar goes to the state like it is disabled.(Image attached for reference)

    After the modeless dialog is gone, then the QScrollBar is normal again.

    1.Why during the execution of modeless dialog, scrollbar changes its value?
    2.How to make the scrollbar normally visible during the execution of modeless dialog box?


  • Moderators

    I'm guessing you're doing something like this:

    • show dialog
    • call processEvents()
    • do some lengthy processing
    • hide dialog

    Is that true? If yes then that's the wrong way to do it. Your window probably freezes and scrollbar just stops repainting.

    The better way to do it is:

    • show dialog
    • start lengthy operation on another thread
    • when the operation is done signal main thread and close dialog in a slot

    This way your main thread will keep processing events, window won't freeze and scrollbar should be fine.

  • @Chris-Kawa Thanks.. Will try the same..

  • Lifetime Qt Champion

    Depepending on what the operation is, you might be able to use

    This sample sounds like what you are trying.


Log in to reply