QTextEdit with Enter in searching
Hi,I’m a newbie here. I just wanna ask about QTextEdit. I want that when I enter a integer in my qtextedit widget, it will search from a database and it will pass the the value to a QTreeWidget if it has that value from database without using the enter button. I hope you could help me. Please. Thank you.
Hi, Thank you so much for your immediate reply. I confess, I’m really newbie here. I already have a python file connecting to my database and I just import it in my main file. But I don’t know how to query like for example, I have a table in my database that is Items. In that table, it has itemcode,description and price. What I want in my project is that my QtextEdit will query the item code in my database and when it finds the item,it will display the item to my Qtreeview. Is this possible? Please help me.
You need subclass QAbstractItemModel [doc.qt.nokia.com] to provide the data model of treeview
and also you can get example of Qt SDK:
PyQt is not a part of the Qt Project anymore. The following is how it is done in PySide(Its official alternative).
The syntax and usage may vary, but the essential idea is the same in both. You can get more info on PyQt syntax somwhere in here [riverbankcomputing.com] or here [riverbankcomputing.com]
- #code here
- #other code here
- def slotForQuery(self) :
- textToQuery = self.myTextEdit.text()
- #rest of the query code here
- #code here
i don’t know anything about database handling, so can’t say anything about that… But for performing something when the text changes in the text edit, this mechanism should work
P.S. you should consider using a QLineEdit instead of QTextEdit if you have to enter only one or two numbers in it(the code above works for it too)