Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextEdit with Enter in searching
QtWS25 Last Chance

QTextEdit with Enter in searching

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 3.2k Views
  • 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 Offline
    N Offline
    nethanjavier
    wrote on last edited by
    #1

    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
    0
    • N Offline
      N Offline
      noregister
      wrote on last edited by
      #2

      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
      0
      • N Offline
        N Offline
        nethanjavier
        wrote on last edited by
        #3

        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
        0
        • N Offline
          N Offline
          noregister
          wrote on last edited by
          #4

          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
          0
          • N Offline
            N Offline
            nethanjavier
            wrote on last edited by
            #5

            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
            0
            • N Offline
              N Offline
              nethanjavier
              wrote on last edited by
              #6

              Hi again,

              Can you please help me on this? Please.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                raaghuu
                wrote on last edited by
                #7

                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
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved