add of color selector
This commit is contained in:
parent
65e391412e
commit
fe5623b804
@ -7,6 +7,7 @@
|
||||
#include <QLineEdit>
|
||||
#include <QTimer>
|
||||
#include <QTextEdit>
|
||||
#include <QColorDialog>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
@ -286,14 +287,16 @@ void MainWindow::setColor(){
|
||||
QTextEdit* textEdit = qobject_cast<QTextEdit*>(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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user