Unsolved what file layout for my model layout should I be using
-
Hi All,
Just to let you all know I am new at this.I am working on a QsqlTableModel QTableView project using an existing SQLITE db.
After several attempts at this, I ended up having to subclass QSortFilterProxyModel (I Think that is what I have done) to filter the 4 lineedits on the first 4 columns of a 13 column tableview, the last setup that I have works to a degree using sortfilterproxymodel.h and main.cpp file setup.
This gives me an issue with buttons to function correctly, then had to create and use buttons.h file for this.Question. Is this the only way to set this model up for filtering lineedits to work, or could someone please suggest a file layout I should be looking at including the best way to filter the four columns on my model.
using the sortfilterproxymodel.h and main.cpp file setup does not seem right to me.
btw - I am NOT using QtCreator's ui file facility, I am creating gui from my own code.
Layout: tableview, buttons, lineedits.Thank you in advance.
-
@ancient-one said in what file layout for my model layout should I be using:
to filter the 4 lineedits on the first 4 columns of a 13 column tableview
This gives me an issue with buttons to function correctly
set this model up for filtering lineedits to work
best way to filter the four columns on my modelWhat does this mean? "filtering" refers to removing rows (or columns) in the model from being displayed to the user in the view. That's what the filtering of
QSortFilterProxyModel
is for. You don't "filter" widgets. But I don't think you are removing anything?What are these line edits/buttons about? And you are talking about widgets on the
QTableView
you display, right (and why do you have widgets on it anyway)? Not widgets which are outside the table view and refer to values in the current row being displayed to the user, like a row editor, right?what file layout for my model layout should I be using
please suggest a file layout I should be looking atWhat do you mean by a "file layout"? (Hopefully this may become intelligible when you answer the earlier question.)
-
Hi JonB
Sorry for my unintelligible question,
I am new to C++ Qt5I have a tableView with 13 columns,
the first 4 columns of the tableview are the columns that are to be filtered using the 4 lineedits independently
One lineedit to filter one column
the buttons are for CRUD + print layout and printing.
File layout - wrong terminology
is there another way to perform these actions other than using
sortfilterproxymodel.h, button.h and main.cpp file setup, because the only way I have found for this to work is using
[https://stackoverflow.com/questions/39488901/change-qsortfilterproxymodel-behaviour-for-multiple-column-filtering?rq=1](link url)
This method does not seem right to me, to what I have learn't to date, and I am still learning, as you know you never stop learning. -
@ancient-one said in what file layout for my model layout should I be using:
the first 4 columns of the tableview are the columns that are to be filtered using the 4 lineedits independently
One lineedit to filter one columnYou are saying the same as before. As already said, I have no idea what this means. I asked you what "filtering a column" means (to you)? Where are these line edits? How does a line edit filter a column?
Maybe if you showed a screenshot I (we?) would understand. Otherwise I'll have to leave you, because I just don't know what you mean/have in mind.
EDIT Am I intended to guess: you have 4 line edits separate from the table, the user can type values into each of these, if so the value used there is going to be used to filter which rows are to be shown in the table, each line edit corresponds to a different column in the table to be searched. Is that it?
In which case, yes, a
QSortFilterProxyModel
where you overridefilterAcceptsRow()
to compare what is in your line edits against each row content, executing an AND or an OR as you decide, is the right thing to do.