0

Say there's a QTableWidget filled with a user's data, and he/she wants to be able to perform an "advanced search" on it using multiple user-defined conditional statements: how would one (the programmer, not the user) go about implementing a function in the code that enables the user to perform this search?

For example, let's say the user wants results of the following search:

(column1 > 20 AND column2 < 50) OR column3 = "cloud"

The first approach that comes to mind would be to somehow take the user's search criteria and generate some kind of 'metacode', but I have no idea how this would work.

3
  • Sound like your says do just like "SQL" query command ??? Commented Sep 6, 2014 at 9:36
  • where/how do you want search result to be shown? Commented Sep 8, 2014 at 8:11
  • In the QTableWidget, eventually, but displaying the results can only be done once the user-defined query is performed. My question relates to how the user-defined query is performed in the fist place. Commented Sep 8, 2014 at 9:49

1 Answer 1

2

First you write a parser and then you define a function/grammar column that gives you the content of a column of your table depending on the current row. Then you go through every row, evaluate the parsed expression and return all the rows that evaluated positively.

For more information on how to write a parser see for example Recursive descent parser.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. I believe I will try to implement the answer given here: stackoverflow.com/questions/25774151/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.