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. Updating property of sibling when pseudo-element changes
Forum Updated to NodeBB v4.3 + New Features

Updating property of sibling when pseudo-element changes

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 446 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.
  • J Offline
    J Offline
    Josef Lintz
    wrote on last edited by
    #1

    Not sure if I'm using the right terminology, so bear with me.

    I have a QCheckbox, and a QWidget (it can be a text, button, etc..) somewhere in my form.
    I want to know if it's possible to set the QWidget's enabled state, from the QCheckbox's checked pseudo-element.

    In C++ code this is what I mean

    void on_QCheckbox_stateChanged(int checked)
    {
        if(checked == 2)
            ui->QWidget->setEnabled(true);
        else if(checked == 0)
            ui->QWidget->setEnabled(false);
    };
    

    Is this possible using only stylesheets?

    JonBJ 1 Reply Last reply
    0
    • J Josef Lintz

      Not sure if I'm using the right terminology, so bear with me.

      I have a QCheckbox, and a QWidget (it can be a text, button, etc..) somewhere in my form.
      I want to know if it's possible to set the QWidget's enabled state, from the QCheckbox's checked pseudo-element.

      In C++ code this is what I mean

      void on_QCheckbox_stateChanged(int checked)
      {
          if(checked == 2)
              ui->QWidget->setEnabled(true);
          else if(checked == 0)
              ui->QWidget->setEnabled(false);
      };
      

      Is this possible using only stylesheets?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Josef-Lintz
      No, because (even if it were possible to read some other widget's state in a different widget, which it is not) stylesheets can do nothing other than visual appearance, they cannot do any kind of "action", such as altering enablement state.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Josef Lintz
        wrote on last edited by Josef Lintz
        #3

        I see so you can't change the enabled state, using a stylesheet. That's unfortunate.
        Is there a way to change the visual appearance of sibling using another's pseudo-element?

        Similar to my C++ example, with a different property than enabled, say,background-color?

        JonBJ 1 Reply Last reply
        0
        • J Josef Lintz

          I see so you can't change the enabled state, using a stylesheet. That's unfortunate.
          Is there a way to change the visual appearance of sibling using another's pseudo-element?

          Similar to my C++ example, with a different property than enabled, say,background-color?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Josef-Lintz
          Stylesheets really are only for changing the visual appearance of elements, nothing more. For example, they can alter how an enabled/disabled item looks, but not whether they are/are disabled.

          As I also wrote

          (even if it were possible to read some other widget's state in a different widget, which it is not)

          so, no, you cannot "change the visual appearance of sibling using another's pseudo-element".

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Josef Lintz
            wrote on last edited by
            #5

            As I also wrote

            (even if it were possible to read some other widget's state in a different widget, which it is not)

            Oh, apologies, I missed that.
            That's very unfortunate. Thanks anyway.

            JonBJ 1 Reply Last reply
            0
            • J Josef Lintz

              As I also wrote

              (even if it were possible to read some other widget's state in a different widget, which it is not)

              Oh, apologies, I missed that.
              That's very unfortunate. Thanks anyway.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @Josef-Lintz
              Not that I have ever used QML, but I understand this is what its "property binding" system is good for. If you were using HTML + CSS, you would have to code this action in JavaScript. In Qt you must do it just the way you showed with a signal/slot action.

              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