diff --git a/mainwindow.cpp b/mainwindow.cpp index 6eb2ac8..02454c0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -7,6 +7,7 @@ #include #include #include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) @@ -286,14 +287,16 @@ void MainWindow::setColor(){ QTextEdit* textEdit = qobject_cast(focused); if (textEdit) { + QColor color = QColorDialog::getColor(Qt::black, this, "Choisir une couleur"); QTextCursor cursor = textEdit->textCursor(); if (cursor.hasSelection()) { - QTextCharFormat format; - format.setForeground(QBrush(QColor(255,0,0))); - cursor.mergeCharFormat(format); + if (color.isValid()) { + QTextCharFormat format; + format.setForeground(color); + cursor.mergeCharFormat(format); + } } } - } void MainWindow::on_actionColor_triggered()