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. how to get foreground color for string
Qt 6.11 is out! See what's new in the release blog

how to get foreground color for string

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 1.4k 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.
  • K Offline
    K Offline
    karti gesar
    wrote on last edited by
    #1

    Hi All...Kindly answer this

    QineEdit * Layout->setText(txtSensor->text());
    QString measure=Layout->text();

    from the above code...i want to change the string color

    raven-worxR 1 Reply Last reply
    0
    • K karti gesar

      Hi All...Kindly answer this

      QineEdit * Layout->setText(txtSensor->text());
      QString measure=Layout->text();

      from the above code...i want to change the string color

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @karti-gesar
      either with this approach.

      Or by simply setting a stylesheet on the QLinEdit:

      lineEdit->setStyleSheet("color: green;");
      

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      4
      • K Offline
        K Offline
        karti gesar
        wrote on last edited by
        #3

        if two string eg: Qstring str1="welcome"; QString str2="hello"; are displayed in single Qlinedit..... output:welcome hello
        here i want to change the color of the welcome and hello

        mrjjM 1 Reply Last reply
        0
        • K karti gesar

          if two string eg: Qstring str1="welcome"; QString str2="hello"; are displayed in single Qlinedit..... output:welcome hello
          here i want to change the color of the welcome and hello

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          hI
          What @raven-worx said:
          does color the text?

          1 Reply Last reply
          0
          • K Offline
            K Offline
            karti gesar
            wrote on last edited by
            #5

            u are right ...that came...hello should be in one color and world should be in different color

            mrjjM 1 Reply Last reply
            0
            • K karti gesar

              u are right ...that came...hello should be in one color and world should be in different color

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @karti-gesar
              hi
              you must then format each word.
              The link he provided shows a function to do so.

              1 Reply Last reply
              2
              • K Offline
                K Offline
                karti gesar
                wrote on last edited by
                #7

                thanks i will try

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  karti gesar
                  wrote on last edited by
                  #8

                  got output i used Qfontmetrics to solve my problem

                  1 Reply Last reply
                  1

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved