[PyKDE] QTableView vs QTableWidget
Andreas Pakulat
apaku at gmx.de
Thu Feb 1 01:53:41 GMT 2007
On 01.02.07 01:20:40, Paulino wrote:
> It's an invoicing app that I'm working on. The main dialog, will send data to
> several tables: invoices, invoices lines, products, customers.
>
> What is the best approach:
>
> The QSqlQueryModel with writing flags and QtableView or QtableWidget? What are
> the pro's and con's of each?
Well, view's are meant to be used with models and give you the full
control over their behaviour, however it takes more time to understand
all parts. Widgets on the other hand hide a good part of the model-stuff
but allow for much easier setup of simple stuff like showing a small
table of items.
> In the first one I don't see yet how I can handle the multiple inserts and
> updates.
You mean you want to insert multiple new rows at once? no problem,
create a button for that and call the models insertRows() function
(button may be a context menu entry too). As for updates, like setting
all values of a column to a specific value, same thing except this time
you'd have to call the models setData() for each row and the changed
column.
> QValidators don't seem to work with cells of both widgets, I have to implement
> the method by hand?
If you want a validator on the input create a custom delegate which
provides a lineedit (or whatever you want there) widget which has a
validator set on it as editing widget.
Andreas
--
You are as I am with You.
More information about the PyQt
mailing list