QTextEdit auto text finisher - c++

Is there any QT class for creation text finisher (If I type "hel", it will automatically finished word with "lo")? Sorry for bad terminology, I don't know how to describe it better.

There is QCompleter but that works an QLineEdit and QComboBox by default only. I never used it but I suppose it should be possible to attach it to a customized QTextEdit too.
Maybe google with QCompleter and QTextEdit as keywords.

Related

How to choose in which QLineEdit should my text put in

I'm working on a project where i have some qpushbuttons and some QlineEdit using qt c++. I want to choose in which QLineEdit my text should be appear. As far I put some text only in the first QLineEdit and the other is filled by condition depending on the first
QInputDialog is a way to get user input.
And I think you need QInputDialog::getItem to choice one of many things.

Qt - retrieving text from QTextBrowser

This seems like it should be very straightforward, and I hope I'm just accidentally overlooking something simple. I have a dialog in my Qt (4.7) project with a QTextBrowser object. At a certain point in the code, I need to access the text inside this QTextBrowser, but while I found functions in the docs to set the text, I'm not seeing anything to get the text. Is there a way to do this? Thanks!
In documentation you can see
Inherits: QTextEdit.
List of all members, including inherited members
So this should work for QTextBrowser QString QTextEdit::toPlainText()
i.e
QString text = textBrowser.toPlainText();

Qt - ComboBox automatically in TableView?

So in my project, I had a TableView and i edited some of its info's in the Qt Editor itself. I also implemented all the codes for it and when I ran before, I could see a comboBox in a place of int. But for some reasons I had to replace that TableView with a new one. All the codes are the same, but I don't see any comboBox now. So does that mean the comboBox appeared for something done in the Editor?
If you replaced your TableView in the qt designer and gave it the same name as before it shouldn't do anything to your c++ implementation of your class. The settings you enter in the qt designer will be deleted when you delete the TableView and you have to re-enter the ones you had before. So you can still use your previous c++ implementation of your class.
I usually design my gui in qt designer and then create a class that sets up signals/slots and initializes the widgets to my liking. So if you had setup your widgets from your class constructor you wouldn't have to worry about any of this.
Good luck!

QCompleter for QTableWidgetItem to autocompelte

I have a QTableWidget has a QTableWidgetItem that contains a code a user will supply. This code is known to the database and is suppose to autosuggest to the user as he types. How do I connect a QCompleter to a QTableWidgetItem. I know how to do it with a QLineEdit, but I have not found an example with a QTableWidgetItem.
I managed to come up with a solution, though not exactly by using a QTableWidgetItem, basically I placed a QLineEdit in the cell instead and attached the QCompleter to that.
Not sure how far this will get you, but take a look at this
http://docs.huihoo.com/qt/4.4/demos-spreadsheet-main-cpp.html
Search for completer in the code.

Qt - How to do superscripts and subscripts in a QLineEdit?

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);
}
QLineEdit wasn'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 a QTextEdit, 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 inherit QLineEdit and do your own drawing, or to make your own widget completely that appears similar to the QLineEdits do.