PDA

View Full Version : select and edit like Microsoft Access with cute sql?



Everall
18th December 2010, 02:54
Hello guys and girls,
I’ve been playing around with onmanualsubmit, onfieldchange and onrowchange when trying to add an empty row on the bottom of a QTableview with a model getting data from a sqlite database.
I think I should use onfieldchange to accomplish this.But I’m stuck.
This is what I want (see image)

When a tableview is not active, I always want an empty row at the bottom. Ok that’s easy : just use insertrow and you have it.
When you go to another cell in the same row or another row, the new row should get submitted to the database and a new empty row is presented at the bottom.
1) Is onfieldchange the good choice?
2) Which eventfilter should I use to tell the tableview it should submit the data and create a new empty row at the bottom. Or is there a better way to accomplish this? I looked into signals, but didn’t come up with a good solution.
All ideas and suggestions are welcome.

Everall5629

wysota
18th December 2010, 09:42
1) Is onfieldchange the good choice?
Seems so.


2) Which eventfilter should I use to tell the tableview it should submit the data and create a new empty row at the bottom.
You can submit the data when quitting the application.


Or is there a better way to accomplish this? I looked into signals, but didn’t come up with a good solution.
Consider implementing a proxy model that will handle the "*" row in the way that it inserts a new row into the base model only when it is complete (i.e. all required columns are populated with data).

Everall
18th December 2010, 20:58
Thx wysota,

Your idea to wait submitting the data to the databases seems rather severe at first, but after some more tought, I'm going to test it out. Probably I will end up submitting after a row has data in every cell, because I observed that qt needs all the cells filled in as you mentioned.

I know proxymodel has filtering sorting/approach. But your point of view is totally new to me. so I will get to study it.
Any good docs, tutorials, examples you know of besides the trolls docs?

Everall

wysota
19th December 2010, 00:32
Probably I will end up submitting after a row has data in every cell, because I observed that qt needs all the cells filled in as you mentioned.
Qt only needs the primary key to be present. It does make sense to submit the row only when all of the obligatory data of a row is provided though.


I know proxymodel has filtering sorting/approach. But your point of view is totally new to me. so I will get to study it.
If you know design patterns then consider a proxy model a decorator of the QAbstractItemModel class. If you don't know design patterns then consider the proxy model as a way to slightly modify the behaviour of the original class without changing its API.


Any good docs, tutorials, examples you know of besides the trolls docs?
It really depends on what you are after. Getting to know the decorator pattern is a good start.

Everall
19th December 2010, 12:37
thx for the directions,

Everall