Results 1 to 3 of 3

Thread: Highlidhting a single QChar in QLineEdit.

  1. #1

    Default Highlidhting a single QChar in QLineEdit.

    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:

    Qt Code:
    1. QPalette palette = ui->input->palette();
    2. palette.setColor(QPalette::Text, Qt::red);
    3. ui->input->setPalette(palette);
    4. ui->input->repaint();
    To copy to clipboard, switch view to plain text mode 

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

    Thanks in advance for your help.

  2. #2
    Join Date
    Jan 2006
    Posts
    369
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Highlidhting a single QChar in QLineEdit.

    use a QTextEdit/QSyntaxHighlighter and force the QTextEdit to have the height of one row.

    In short - no.

  3. #3

    Default Re: Highlidhting a single QChar in QLineEdit.

    Well that's a wee bit disappointing, but thanks. Will use the QTextEdit/QSyntaxHighlighter trick.

Similar Threads

  1. Replies: 4
    Last Post: 15th July 2008, 01:18
  2. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.