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. A widget to display text
Forum Updated to NodeBB v4.3 + New Features

A widget to display text

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 19.7k 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.
  • B Offline
    B Offline
    bright day
    wrote on last edited by
    #1

    Hi! I'm looking for a widget to display rich text (I'm gonna use it in QTableWidget via setCellWidget(..)).
    First I thought QLabel was a good solution, but it was not. What is the best alternative to have rich text, background customizing and also frame width, style and color customizing in my text widget?

    1 Reply Last reply
    0
    • ZlatomirZ Offline
      ZlatomirZ Offline
      Zlatomir
      wrote on last edited by
      #2

      "QTextEdit":http://doc.qt.nokia.com/latest/qtextedit.html#details class might be what you are looking for.

      https://forum.qt.io/category/41/romanian

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bright day
        wrote on last edited by
        #3

        thank you. Do you know how I can change border color of the QTextEdit?

        And if I have about 40-50 QTextEdits in one window, will it cause serious CPU load ?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          you can easily change colour of text and background using setTextColor() and setTextBackgroundColor(). Changing the border of the text edit itself would - as far as I remember - require using QSS, subclassing, or even own style creation.

          (Z(:^

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bright day
            wrote on last edited by
            #5

            thank you for reply
            setTextBackgroundColor() changes background of the text, when I need changing background of the widget. (color should change depending on whether focus is on widget or not)
            what is the best way to do this, who knows?

            1 Reply Last reply
            0
            • EddyE Offline
              EddyE Offline
              Eddy
              wrote on last edited by
              #6

              bq. First I thought QLabel was a good solution

              Could you tell us why it's not a good solution for you? I t can help us understand what you really want.

              bq. What is the best alternative to have rich text, background customizing and also frame width, style and color customizing in my text widget?
              Are those the only things you want to accomplish?

              Did you try "stylesheet examples":http://doc.qt.nokia.com/4.7/stylesheet-examples.html?

              Qt Certified Specialist
              www.edalsolutions.be

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                I'm looking through Qt textbook right now, it seems that - as I've mentioned - it is possible through QSS.

                Try this:
                @
                // use your QTextEdit, of course:
                QTextEdit test;
                test.setStyleSheet("border: rgb(255, 0, 0); ");
                @
                You can use common colour names, too. For more info, look into documentation:
                "Qt Style Sheet":http://developer.qt.nokia.com/doc/qt-4.7/stylesheet.html#id-7e8519ff-eddd-442c-ad11-e4519ccf273a

                (Z(:^

                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