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. textBrowser - setEnabled problem
Forum Updated to NodeBB v4.3 + New Features

textBrowser - setEnabled problem

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 1.2k Views 3 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.
  • kajzerK Offline
    kajzerK Offline
    kajzer
    wrote on last edited by
    #1

    Seems like setEnabled isn't working when text color for textBrowser is changed.

    ui->textBrowser->setTextColor(QColor("#45EEFE"));
    ui->textBrowser->setText("Some text");
    ui->textBrowser->setEnabled(false);
    

    If I don't change the color then it works fine.
    Am I missing something ?

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

      Hi and welcome to devnet,

      What are you expecting from setEnabled ?
      What are you currently getting ?
      With which version of Qt ?
      On which platform ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • kajzerK Offline
        kajzerK Offline
        kajzer
        wrote on last edited by
        #3

        Hi, sorry if I wasn't clear enough.

        setEnabled actually works as it should (not visually), for example if you setEnabled(false) for a pushbutton you wouldn't be able to click it, but the same thing happens with pushbutton as with textBrowser if you change the color :
        ui->pushButton->setStyleSheet("color: rgb(255, 0, 0)");

        I guess this happens with any widget, what happens is that the color of a widget stays the same and it should be grayed out, like it does when you don't change a color, basically that's the problem.

        Qt is 5.9 on linux.

        JonBJ J.HilkJ 2 Replies Last reply
        0
        • kajzerK kajzer

          Hi, sorry if I wasn't clear enough.

          setEnabled actually works as it should (not visually), for example if you setEnabled(false) for a pushbutton you wouldn't be able to click it, but the same thing happens with pushbutton as with textBrowser if you change the color :
          ui->pushButton->setStyleSheet("color: rgb(255, 0, 0)");

          I guess this happens with any widget, what happens is that the color of a widget stays the same and it should be grayed out, like it does when you don't change a color, basically that's the problem.

          Qt is 5.9 on linux.

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

          @kajzer
          I think you're stating that without an explicit color disabled changes color, but once a color is specified explicitly it does not. Explicit color overrides default behaviour. To get the "dimming" I believe you have to now choose a dimmed color and attach via something like QPushButton:disabled (or however you specify that property in stylesheet?), or set dimmed color explicitly in code on disablement.

          1 Reply Last reply
          1
          • kajzerK kajzer

            Hi, sorry if I wasn't clear enough.

            setEnabled actually works as it should (not visually), for example if you setEnabled(false) for a pushbutton you wouldn't be able to click it, but the same thing happens with pushbutton as with textBrowser if you change the color :
            ui->pushButton->setStyleSheet("color: rgb(255, 0, 0)");

            I guess this happens with any widget, what happens is that the color of a widget stays the same and it should be grayed out, like it does when you don't change a color, basically that's the problem.

            Qt is 5.9 on linux.

            J.HilkJ Online
            J.HilkJ Online
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @kajzer you need to adjust your StyleSheet for the textbrowser, something like this:

            ui->textBrowser->setStyleSheet("QTextBrowser{color:red;} QTextBrowser:disabled{color:white;}");


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            kajzerK 1 Reply Last reply
            1
            • J.HilkJ J.Hilk

              @kajzer you need to adjust your StyleSheet for the textbrowser, something like this:

              ui->textBrowser->setStyleSheet("QTextBrowser{color:red;} QTextBrowser:disabled{color:white;}");

              kajzerK Offline
              kajzerK Offline
              kajzer
              wrote on last edited by kajzer
              #6

              @J.Hilk said in textBrowser - setEnabled problem:

              ui->textBrowser->setStyleSheet("QTextBrowser{color:red;} QTextBrowser:disabled{color:white;}");

              This works, thanks!

              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