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. Stylesheet bug(?) on a qplaintextedit
Qt 6.11 is out! See what's new in the release blog

Stylesheet bug(?) on a qplaintextedit

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 2.6k 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.
  • ExcludosE Offline
    ExcludosE Offline
    Excludos
    wrote on last edited by
    #1

    I'm working on an application where I've put a qplaintextedit on a popup (Switching between plaintextedit and textedit makes no difference for this issue). Now I'm trying to change the color of the widget and am facing some annoyance:

    These are the two qss lines that impact this widget:

    QWidget { background-color: rgb(57,60,62); }
    QPlainTextEdit {background-color: blue; color: pink;}

    And for a long time, I couldn't get it to change background at all. It does read the qss itself, because the color of the text kept changing. Then I added this line:

    ui->plainTextEdit->setBackgroundVisible(true);

    And got this result:
    texteditbug

    What in the world is going on here? Why is part of the background blue as it's suppose to be but not the part where I actually input the text? Starting a new application I can not reproduce this, but neither can I find any reason as to why this should be happening to begin with. Any tips or ideas would be appreciated. I'm ripping my hair out over here.

    Qt version is 5.9 msvc 2015 32 bit (same issue on 5.7), qtcreator is 4.3.0. Environment is Windows 10.

    1 Reply Last reply
    0
    • ExcludosE Offline
      ExcludosE Offline
      Excludos
      wrote on last edited by
      #2

      After looking through my application for a few hours, I found a reason altough not a fix for the bug. This only occurs on my custom window dialog. If I use a regular dialogwindow everything works fine.

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

        Hi,

        Can you show the exact code that triggers that ?

        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
        • ExcludosE Offline
          ExcludosE Offline
          Excludos
          wrote on last edited by
          #4

          There's really not a lot of code to show (plus it's all a bit of a spaghetti between several classes). The plaintextedit itself is initiated in QT Designer, which is placed inside a widget which in itself is placed inside custom window. I can't show you any code, but I can show you the workaround I ended up using:

          this->setStyleSheet("background-color: none");
          QPalette p = this->palette();
          p.setColor(QPalette::Base, QColor::fromRgb(57,60,62));
          this->setPalette(p);
          

          The important bit being the "setstylesheet" to have the color "none", as otherwise it would inherit from the stylesheet's qwidget color (which doesn't work in this case).

          If I get the time, I'll try to replicate it in a completely new project which I can share here, so we can try to solve the issue itself instead of hiding the symptoms.

          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