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] help with qcolor with textedit
QtWS25 Last Chance

[SOLVED] help with qcolor with textedit

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.2k Views
  • 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
    kalster
    wrote on last edited by
    #1

    i would like to use the qcolor but i don't know how. when the pushbutton is clicked, I have a plainTextEdit and i would like to paste the results in the plainTextEdit input box, where the user types. eg, color #000000. can someone please help in this matter. i need an example. thank you in advanced.

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

      "Here is an example":http://developer.qt.nokia.com/doc/qt-4.7/dialogs-standarddialogs-dialog-cpp.html with code that uses qcolordialog.

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kalster
        wrote on last edited by
        #3

        i was asking for a textedit example. the above link does not have that example. what i need is a color for the textEdit when the Qcolor is selected. for example, when the user clicks a color in the color dialog, the color code is then displayed in the textEdit output box.

        below is my attempt to get the Qcolor code displayed in the textEdit. i get the error: no match for 'operator+' in '"<b><font color=#" + test' in the last line of code.
        @ QColor test = QColorDialog::getColor (Qt::white, this);
        textEdit[0]->append(QString("<b><font color=#"+test+">%1</font></b>"));@

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kalster
          wrote on last edited by
          #4

          i just solved it with the following code :)

          @ QColor test = QColorDialog::getColor (Qt::white, this);
          message = message.insert(selectEnd, "</font>");
          message = message.insert(selectStart, "<font color="" + test.name()+ "">");@

          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