QColor name to rgb name



  • Hellow, how can i get rgb name from QColor
    For example
    I have QColor = Qt::black
    how can i get "rgb(0,0,0)"
    I try it:
    @c.toRgb().name()@
    But it is get me #000000 instead of rgb(0,0,0);
    Advance many thanks for your help



  • if you need rgb(0,0,0), you can do:

    @
    QColor c = Qt::black;
    QString text = QString("rgb(%1,%2,%3)").arg(c.red()).arg(c.green()).arg(c.blue());
    @

    Code is not tested, just written here



  • Try this:
    @
    QColor c;
    //
    QString name = QString("rgb(%1,%2,%3)").arg(c.red()).arg(c.green()).arg(c.blue());
    @
    *EDIT:*As Gerolf said... >:(


Log in to reply
 

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