I need to have the ability to use superscripts asnd subscripts in a QLineEdit in Qt 4.6. I know how to do superscripts and subscripts in a QTextEdit as seen below but I can’t figure out how to do them in QLineEdit because the class doesn’t contain a mergeCurrentCharFormat() function like QTextEdit does. Please help. Thanks
void MainWindow::superscriptFormat()
{
QTextCharFormat format;
format.setVerticalAlignment(QTextCharFormat::AlignSuperScript);
if(ui->txtEdit->hasFocus())
ui->txtEdit->mergeCurrentCharFormat(format);
}
QLineEditwasn’t really made for this type of thing, as it was designed for simple text entry. You have a few options, however. The simplest one is to do as Hostile Fork suggested and use aQTextEdit, and add a style override to not show the scroll bar (which I assume would remove the arrows). The more complex one would be to either inheritQLineEditand do your own drawing, or to make your own widget completely that appears similar to theQLineEdits do.