PDA

View Full Version : Highlidhting a single QChar in QLineEdit.



Zenzen
7th January 2009, 21:03
Hi,
I was wondering is it possible to change the colour of a single QChar in a QLineEdit. I'm writing a simple programme to visualise some basic cipher algorithms and during the simulation I would like it to highlight the QChar (that's part of a QString in the QLineEdit) that's currently being ciphered. Unfortunately all I was able to do is to highlight the whole text in QLineEdit with something like this:


QPalette palette = ui->input->palette();
palette.setColor(QPalette::Text, Qt::red);
ui->input->setPalette(palette);
ui->input->repaint();

Where ui is my main window and input is of course the QLineEdit.

Thanks in advance for your help.

elcuco
7th January 2009, 21:07
use a QTextEdit/QSyntaxHighlighter and force the QTextEdit to have the height of one row.

In short - no.

Zenzen
7th January 2009, 21:15
Well that's a wee bit disappointing, but thanks. Will use the QTextEdit/QSyntaxHighlighter trick.