PDA

View Full Version : QTableView and regexp



gnogno35
23rd May 2016, 17:08
Hello,

I have to port an existing application to Qt (5.6) ... and try to display data (from SQL) in a QTableView.

The problem is that I want to have an editable row ABOVE the header of the QTableView to type some regexp to filter the content of any column.
I have no idea how to do that :
- write a custom QTableView ?
- write a custom QHeaderView ?
- other ?

Thanks for your help ...

anda_skoa
23rd May 2016, 17:37
Above the header?

Couldn't that easily be solved by having a QLineEdit above the table view and within the same QVBoxLayout?

Cheers,
_

gnogno35
24th May 2016, 09:12
Above the header?

Couldn't that easily be solved by having a QLineEdit above the table view and within the same QVBoxLayout?

Cheers,
_

Thanks for your interest ...

But with your suggestion I'd need one QLineEdit per column and they all have to resize the same way the columns do !
Looks quite complicated to manage ... and the only solution I imagined ... :-(

anda_skoa
24th May 2016, 11:32
Ah, hmm.

Then maybe instead of a single line edit a QHBoxLayout of line edits, each line edit with a fixed width corresponding to the respective section width of the header view.
Then also connect to the header view's sectionResized() signal and adjust the fixed width of the line edit for that section.

Cheers,
_

ReshmaRatan
25th May 2016, 11:10
Hello,

I have to port an existing application to Qt (5.6) ... and try to display data (from SQL) in a QTableView.

The problem is that I want to have an editable row ABOVE the header of the QTableView to type some regexp to filter the content of any column.
I have no idea how to do that :
- write a custom QTableView ?
- write a custom QHeaderView ?
- other ?

Thanks for your help ...

Hello,

Its little bit complex way of creating them. You can refer to the sqlitebrowser code, in sqlite browser we have similar functionality of providing a line edits for all the columns below the header which helps in filtering the data. You can find the sqlitebrowser code in the following site (http://sqlitebrowser.org/)

Hope it helps....