Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QTextEdit with Enter in searching

    General and Desktop
    3
    7
    2941
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nethanjavier last edited by

      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.

      Best Regards,
      Nethan

      1 Reply Last reply Reply Quote 0
      • N
        noregister last edited by

        add one SLOT method,and connect it to the Signal of QTextEdit.textChanged.
        do your database query and so on in the SLOT.

        1 Reply Last reply Reply Quote 0
        • N
          nethanjavier last edited by

          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.

          Best Regards,
          Nethan

          1 Reply Last reply Reply Quote 0
          • N
            noregister last edited by

            You need subclass "QAbstractItemModel":http://doc.qt.nokia.com/4.7-snapshot/qabstractitemmodel.html to provide the data model of treeview

            and also you can get example of Qt SDK:
            QtSDK\Examples\4.8\itemviews\simpletreemodel
            QtSDK\Examples\4.8\itemviews\addressbook
            l

            1 Reply Last reply Reply Quote 0
            • N
              nethanjavier last edited by

              Hi Again,

              I saw these examples but they are all built in C++. I'm currenlt using PyQt. Is there any example out there?

              1 Reply Last reply Reply Quote 0
              • N
                nethanjavier last edited by

                Hi again,

                Can you please help me on this? Please.

                1 Reply Last reply Reply Quote 0
                • R
                  raaghuu last edited by

                  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":http://www.riverbankcomputing.com/static/Docs/PyQt4/html/classes.html or "here":http://www.riverbankcomputing.com/static/Docs/PyQt4/html/index.html

                  @
                  #code here

                  self.myTextEdit.textChanged.connect(slotForQuery)

                  #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)

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post