[SOLVED] help with qcolor with textedit



  • 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.


  • Moderators

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



  • 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>"));@



  • 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()+ "">");@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.