Getting background color of a frame value in a Label

  • I am trying to get the red value of the background color of a frame, to put it into a label.
    This color value has been set by a QColorDialog, and applied with QPalette.
    There is no value in my label... What am I doing wrong?

    Here's the code

    void PatternEditor::on_boutonCouleurInit_clicked()
    QColor couleur = QColorDialog::getColor(Qt::white, this); //sets couleur with QColorDialog

    QPalette palette; 
    palette.setColor(QPalette::Background, couleur); //sets background color
    ui->initColorWidget->setPalette(palette); //apply color to the background's frame
    ui->codeCouleurInitLabel->setText(QChar(; //(should) set text of my label with the red color value of couleur


  • Fixed... In fact, it was just a matter of QChar translation...

Log in to reply