add of color selector
This commit is contained in:
parent
65e391412e
commit
fe5623b804
@ -7,6 +7,7 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
#include <QColorDialog>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
@ -286,14 +287,16 @@ void MainWindow::setColor(){
|
|||||||
QTextEdit* textEdit = qobject_cast<QTextEdit*>(focused);
|
QTextEdit* textEdit = qobject_cast<QTextEdit*>(focused);
|
||||||
|
|
||||||
if (textEdit) {
|
if (textEdit) {
|
||||||
|
QColor color = QColorDialog::getColor(Qt::black, this, "Choisir une couleur");
|
||||||
QTextCursor cursor = textEdit->textCursor();
|
QTextCursor cursor = textEdit->textCursor();
|
||||||
if (cursor.hasSelection()) {
|
if (cursor.hasSelection()) {
|
||||||
QTextCharFormat format;
|
if (color.isValid()) {
|
||||||
format.setForeground(QBrush(QColor(255,0,0)));
|
QTextCharFormat format;
|
||||||
cursor.mergeCharFormat(format);
|
format.setForeground(color);
|
||||||
|
cursor.mergeCharFormat(format);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionColor_triggered()
|
void MainWindow::on_actionColor_triggered()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user