[Qt-interest] Hide deleted rows in QSqlTableModel
wim.delvaux at adaptiveplanet.com
wim.delvaux at adaptiveplanet.com
Sun Nov 29 23:21:49 CET 2009
Perhaps use a Proxy model ? QSortFilterProxyModel ?
W
On Saturday 28 November 2009 18:36:13 Thomas Richard wrote:
> Hey,
>
> First of all, thanks for the replies!
>
> On Saturday 28 November 2009 17:12:55 Sean Harmer wrote:
> > > The only way i found so far is to connect an own slot to
> > > <table model>->headerDataChanged (...)
> > >
> > > Inside this method i code the following:
> > > ---------------- cut --------------------
> > > void Class::OwnHeaderChanged (Qt::Orientation orientation, int start,
> > > int end) {
> > > if (orientation != Qt::Vertical)
> > > return;
> > >
> > > for (int loop = start; loop <= end; ++loop)
> > > {
> > > QVariant sign = <table model>->headerData (loop, orientation);
> > > if (sign == QLatin1String ("!"))
> > > ui.<table view>->hideRow (loop);
> > > }
> > > }
> > > ---------------- cut --------------------
>
> That might be a solution. But it's not pretty. You have to make a
> connection every time you want to use this and you have to paste this code
> in every class you use it. (Unless you make your class inherit some other
> class which implements this but that's not an option for me)
>
> > I would guess (but have not tried) that this could be achieved with a
> > fairly simple subclass of QSortFilterProxyModel that sits between your
> > QSqlTableModel and the view. Just do your check in the
> > filterAcceptsRow() virtual function.
>
> I tried this out today but it doesn't work as i expected. The
> filterAcceptsRow() is for some reason not called when i call
> model->deleteRow().
>
> Up until now I'm manually hiding rows when i click the delete button and
> making every row visible again when i call revertAll(). I really need to
> find a better solution though. I'm going to look at subclassing QTreeView
> now and see if i can find something in there to use. I think this should
> become part of Qt though. Some sort of setDeletedRowsHidden(bool). I guess
> that is a feature request ;)
>
> Greetings
> Thomas Richard
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list