From fe5623b8049767c0d9a8851e7f2be1b9192fd56e Mon Sep 17 00:00:00 2001 From: Giovanni JOSSERAND Date: Fri, 20 Jun 2025 16:30:24 +0200 Subject: [PATCH] add of color selector --- mainwindow.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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()