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. [SOLVED] Change stysheet at runtime
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Change stysheet at runtime

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 1.1k 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on 2 Nov 2014, 12:36 last edited by
    #1

    Hello guys!

    I read a lot of topic-relevant tasks but I did not find the answer for my question (Maybe I can not understand the answers 'cause those are too clever :D )

    I would like to update my QLabel objects inside a loop during runtime.
    I am designing an app to step through a list of folders and execute a command with QProcess. Next to the window I show a list of these folders and I would like to change the stylesheet "font-weight: bold;" for the name of the current foder for indicate where the progam is now.
    But my problem is that the ALL stylesheet changes will be executed AFTER the loop went through ALL the folders.

    I use the setStyleSheet() function, and I tried with style()->unpolish(); style()->polish(); update(); methods too but nothing happened during execution.

    Can somebody explain a possible solution or show an example from scratch how can I use attributes for my problem?

    Have a nice day :)

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 2 Nov 2014, 17:25 last edited by
      #2

      You're probably going at it the wrong way. It's not that the stylesheet is not being applied, it's probably your loop that blocks the UI thread and doesn't allow it to apply changes.

      A poor and quick solution would be to call qApp->processEvents() in your loop, but a better one would be to make the thing that is done in the loop an asynchronous action that emits an update signal.

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on 2 Nov 2014, 18:26 last edited by
        #3

        Hi!

        You are right!
        I changed my loop via QProcess to asynchronous and step in another method into the next folder in the SLOT what I connected to the SIGNAL of QProcess finished(int).

        Thank you and I hope it will help to everyone in the future.

        Best regards

        1 Reply Last reply
        0

        3/3

        2 Nov 2014, 18:26

        • Login

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