Results 1 to 7 of 7

Thread: Help about qt and search box

  1. #1
    Join Date
    Jul 2015
    Posts
    4
    Qt products
    Platforms
    Windows

    Default Help about qt and search box

    Hi I'm a new user of QT soI made a script for maya with QT designer so far It has so many buttons with so many names on it as you can see:

    Ok I wanna make a search box that when I write into it things it finds buttons for example if I write lip it goes and finds the first button that has this name on it So How can I do that plz somebody explain about it.I used the 2 files:
    expr.py
    expr.ui
    Okay so I don't know anything about .cpp files or QML or the others Help plz and explain it with picture or video if you can TNX :|

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Help about qt and search box

    Assuming you want a partial name match.

    In pseudo-code...
    Qt Code:
    1. When the user presses your Search button with queryText in a line edit:
    2. Use QObject::findChildren() to locate all QPushButton children of the scroll area
    3. Iterate over all the QPushButton children:
    4. If child text().startsWith(queryText)
    5. scrollArea.ensureWidgetVisible(child)
    6. exit loop
    To copy to clipboard, switch view to plain text mode 
    You could use toLower() to do case-insensitive query, or contains() instead of startsWith().

    For an exact name match findChildren() can do the whole search for you.

  3. #3
    Join Date
    Jul 2015
    Posts
    4
    Qt products
    Platforms
    Windows

    Default Re: Help about qt and search box

    Tnx for your reply dude but I didn't get where should I use it in .py file or .ui where exacly can you show by a picture ?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Help about qt and search box

    The .ui file is a just an XML document describing the UI, it does not contain any code.

    The .py file, on the other hand, is a Python source file, it does contain code.

    Cheers,
    _

  5. #5
    Join Date
    Jul 2015
    Posts
    4
    Qt products
    Platforms
    Windows

    Default Re: Help about qt and search box

    TNX for reply so

    In pseudo-code...
    Qt Code: Switch view
    When the user presses your Search button with queryText in a line edit:
    Use QObject::findChildren() to locate all QPushButton children of the scroll area
    Iterate over all the QPushButton children:
    If child text().startsWith(queryText)
    scrollArea.ensureWidgetVisible(child)
    exit loop

    Where is In pseudo-code to use this code in??if it isn't py and ui file so what is it? it's in QT itself?WHere if you show me by picture I'll be really thankful.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Help about qt and search box

    Quote Originally Posted by kmthrong View Post
    Where is In pseudo-code to use this code in??
    As I explained, the .py file holds the program code.

    Quote Originally Posted by kmthrong View Post
    if it isn't py and ui file so what is it?
    It is Pseudo Code, a human readable description of steps that are necessary to achieve a desired goal.
    The idea is to convey the procedure without having to know the target language in detail.

    In your case the target language seems to be Python, you need to write the respective Python code that performs the steps laid out in the Pseudo Code.

    Cheers,
    _

  7. #7
    Join Date
    Jul 2015
    Posts
    4
    Qt products
    Platforms
    Windows

    Default Re: Help about qt and search box

    TNX I tried to understand but I couldn't get anything because I'm a beginner would you plz upload a video I didn't get your mean !
    This is the py file:
    http://up2www.com/uploads/453fexpr22.rar

    TNX I tried to understand but I couldn't get anything because I'm a beginner would you plz upload a video I didn't get your mean !
    This is the py file:
    http://up2www.com/uploads/453fexpr22.rar

Similar Threads

  1. Replies: 1
    Last Post: 14th November 2012, 21:00
  2. search in sql?
    By fantom in forum Newbie
    Replies: 1
    Last Post: 17th May 2012, 00:42
  3. QTreeView search
    By jpujolf in forum Qt Programming
    Replies: 6
    Last Post: 3rd March 2009, 06:43
  4. Search box?
    By sdfisher in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2007, 18:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.