Results 1 to 6 of 6

Thread: How to build a search tool bar like Wireshark

  1. #1
    Join Date
    Dec 2019
    Posts
    32
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default How to build a search tool bar like Wireshark

    Hi,

    I know this is a broad question. If anyone is familiar with Wireshark, I was wondering how to build a search tool bar using that method.

    What I would like is to build a query tool using a line editBox or something similar which as users type attribute names and a drop down list is is displayed which they can select from (kind of like a combobox). Next they would enter a value followed by a Boolean operator which concatenates multiple requests accordingly. The thing is the parsing of the input data appears to be calculated. Here is an example.

    (ABC.agh > 3 && DEF.gju <= 245.0) OR mmn.kkjds != 100

    So essentially as a user types AB, they get a drop down list such as ABC, ABD, ABL, etc. After they select "ABC.", they get a new list of attributes associated with ABC which in the above case is agf, etc. Once all is entered I need to parse across and evaluate the query.

    I'm just wondering if there is a clever way of doing this may be not an lineEdit Widget, perhaps something different?

    Any help would be appreciated? Could there is a library for this already?

    Thanks!

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to build a search tool bar like Wireshark

    Could there is a library for this already?
    Check out QCompleter. It can at least handle the ABC -> ABCD ABCE ABDF... part. You may be able to combine that with a QValidator that uses regular expressions to ensure the search string is a valid Boolean expression.
    Last edited by d_stranz; 29th January 2020 at 01:42.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Dec 2019
    Posts
    32
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to build a search tool bar like Wireshark

    I'm very familiar with QCompleter but it may help with the search at least partially but how do I add new attributes as I go along in the equation? What is the best widget for this, lineEdit?

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to build a search tool bar like Wireshark

    I was thinking about this some more. I downloaded the Wireshark source code and it looks like the UI is written using Qt. From what I can see there are two classes in the ui/qt directory which might implement the search feature you are talking about: capture_filter_edit.[h, cpp] and capture_filter_syntax_worker.[h, cpp]. The class CaptureFilterEdit is derived from SyntaxLineEdit, which is derived from QLineEdit. At the core is a QCompleter, which works off a QStringList model of tokens, along with a QThread that examines the text for syntax.

    It's pretty complex code, but you might take a look to see if there is anything you can learn from it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Dec 2019
    Posts
    32
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to build a search tool bar like Wireshark

    I do have the Wireshark code but couldn't quite find where they did that functionality. Thanks for your help. I look through it and see if I can get ideas.

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to build a search tool bar like Wireshark

    Check out the files I mentioned - they seem like a logical place for that functionality.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. crash tool static build qt
    By davinciomar in forum Newbie
    Replies: 1
    Last Post: 10th September 2016, 19:35
  2. Qt Creator Cannot setup tool chain to build...
    By Coolname007 in forum Qt Tools
    Replies: 2
    Last Post: 5th October 2012, 04:57
  3. Qt Creator Build Qt 4.7.4 using Intel C/C++ compiler, tool chain creation problems
    By napajejenunedk0 in forum Qt Tools
    Replies: 0
    Last Post: 7th September 2011, 01:50
  4. Qt powered Build tool: R2build
    By r2build in forum Qt-based Software
    Replies: 2
    Last Post: 23rd October 2009, 05:06
  5. Replies: 12
    Last Post: 7th July 2009, 18:32

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.