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. Stylesheets: pseudo states in descendants selectors
Forum Updated to NodeBB v4.3 + New Features

Stylesheets: pseudo states in descendants selectors

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 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.
  • G Offline
    G Offline
    goldstar2154
    wrote on last edited by
    #1

    Is it possible use pseudo-states inside descendants selectors

    For example:
    I need change child label color if parent button have focused state

    QPushButton:focus QLabel
    {
            ...
    	color: #FFFFFF;
    }
    

    But this selector dont works.

    Also i found this topic https://stackoverflow.com/questions/21911820/qt-how-to-set-color-of-child-labels-while-hover-parent-frame but it looks little bit outdated.

    Can someone confirm is it possible use pseudo states inside descendants selectors?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      I don't think so.
      I also tried for :focus but it seems to read it as

      QPushButton QLabel
      {

      }

      and thus ignore the pseudo-state

      Even for a container like QFrame where QLabel is really inside it still ignores
      the:focus part so its doubtfull it can work. ( or at least i didn't find the right formula)

      However, to actually have QLabel inside button must mean you have a custom control
      and hence you could handle it internally via
      void focusInEvent(QFocusEvent* e);
      void focusOutEvent(QFocusEvent* e);

      G 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        I don't think so.
        I also tried for :focus but it seems to read it as

        QPushButton QLabel
        {

        }

        and thus ignore the pseudo-state

        Even for a container like QFrame where QLabel is really inside it still ignores
        the:focus part so its doubtfull it can work. ( or at least i didn't find the right formula)

        However, to actually have QLabel inside button must mean you have a custom control
        and hence you could handle it internally via
        void focusInEvent(QFocusEvent* e);
        void focusOutEvent(QFocusEvent* e);

        G Offline
        G Offline
        goldstar2154
        wrote on last edited by
        #3

        @mrjj my current solution works on overriden focusInEvent/focusOutEvent. Sollution works but i also want mede this only with QSS.
        Thanks for response.

        mrjjM 1 Reply Last reply
        0
        • G goldstar2154

          @mrjj my current solution works on overriden focusInEvent/focusOutEvent. Sollution works but i also want mede this only with QSS.
          Thanks for response.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @goldstar2154
          Hi
          ok, it seems QSS do not support it / ignores it and applies the keys regardless of parent has focus.

          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