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] How to restore QTextEdit original background color?
Forum Updated to NodeBB v4.3 + New Features

[Solved] How to restore QTextEdit original background color?

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 20.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.
  • M Offline
    M Offline
    MuhamedAuda
    wrote on last edited by
    #2

    @rgb(255, 255, 255)@

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hryqt
      wrote on last edited by
      #3

      [quote author="MuhamedAuda" date="1351789762"]@rgb(255, 255, 255)@[/quote]

      No, it's not white. It's like light greyish.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MuhamedAuda
        wrote on last edited by
        #4

        or u can set it in code like this:
        @ this->ui->textEdit->setStyleSheet("background-color: rgb(255, 255, 255)");
        @

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hryqt
          wrote on last edited by
          #5

          [quote author="MuhamedAuda" date="1351790408"]or u can set it in code like this: @ this->ui->textEdit->setStyleSheet("background-color: rgb(255, 255, 255)"); @[/quote]

          That is not my point. What you refer to as rgb(255,255,255) will give "White" color.
          But my original QTextEdit color is not white.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MuhamedAuda
            wrote on last edited by
            #6

            i think the default background color OS color base ...

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hryqt
              wrote on last edited by
              #7

              [quote author="MuhamedAuda" date="1351790782"]i think the default background color OS color base ...[/quote]

              Yes, I agree. It's OS dependent.

              That's why I want to know how to restore it back to its original color after I change it?

              I thought I need to know the original color in order to restore it. Or maybe there's another way to do this.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Jake007
                wrote on last edited by
                #8

                If you want default OS style of an widget, just set style to empty string:
                @setStyleSheet("");@


                Code is poetry

                1 Reply Last reply
                1
                • H Offline
                  H Offline
                  hryqt
                  wrote on last edited by
                  #9

                  [quote author="Jake007" date="1351791547"]If you want default OS style of an widget, just set style to empty string: @setStyleSheet("");@ [/quote]

                  Ah, yes, it works! Thanks a lot!

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    Jake007
                    wrote on last edited by
                    #10

                    I'm glad I could help :) .
                    Please mark topic as solved ( edit your first post and add [Solved] in front of the title).

                    Regards,
                    Jake


                    Code is poetry

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      hryqt
                      wrote on last edited by
                      #11

                      [quote author="Jake007" date="1351791872"]I'm glad I could help :) . Please mark topic as solved ( edit your first post and add [Solved] in front of the title). Regards, Jake[/quote]

                      Done! Thanks, Jake :)

                      Btw, do you happen to know the solution for my other question? (QTextEdit cursor)?

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        MuhamedAuda
                        wrote on last edited by
                        #12

                        yes it work full example
                        @#include <QtGui/QApplication>
                        #include <QWidget>
                        #include <QTextEdit>

                        int main(int argc, char *argv[])
                        {
                        QApplication a(argc, argv);
                        QWidget w;

                        QTextEdit *txtEdit = new QTextEdit(&w);
                        // to change backgournd color
                        txtEdit->setStyleSheet("background-color: rgb(255, 1, 255)"); 
                        // to reset it to default color ...
                        txtEdit->setStyleSheet("");
                        w.show();    
                        return a.exec&#40;&#41;;
                        

                        }
                        @

                        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