Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, February 2007
A lot of rows to display ... heh...


Message 1 in thread

Hello,

I need to build stock-management application, and one of the forms will 
contain a QTableView that will have to show more than a hundred thousand 
rows with ability to edit (rows count will be less if the filters will 
be used). I need to mark some of the rows with different background 
color (not an alternate color), and also ability to keep an empty row at 
the bottom if the user will need to add a new row (fields in the new row 
has to be in the format column in, for instance if the column is float 
the field in the empty bottom row has to be float too).

How is it possible to achieve? Should I use QTableWidget instead to 
display the data?

Best regards,
Oleg Romanenko.

--
 [ signature omitted ] 

Message 2 in thread

On Wednesday 21 February 2007 19:49, Oleg Romanenko wrote:
> Hello,
>
> I need to build stock-management application, and one of the forms will
> contain a QTableView that will have to show more than a hundred thousand
> rows with ability to edit (rows count will be less if the filters will
> be used). I need to mark some of the rows with different background
> color (not an alternate color), and also ability to keep an empty row at
> the bottom if the user will need to add a new row (fields in the new row
> has to be in the format column in, for instance if the column is float
> the field in the empty bottom row has to be float too).
>
> How is it possible to achieve? Should I use QTableWidget instead to
> display the data?
>
> Best regards,
> Oleg Romanenko.
>
> --

Read the part in the documentation about the MVC-pattern and how to use a 
delegate. This will give you some pointers..
-- 
 [ signature omitted ] 

Message 3 in thread

Hello Peter,

Thanks for a reply! I have read about delegates and it seems that they 
completely change the way how data is being edited, and to change just 
the background of some of the rows, I believe it will consume quite a 
lot of resources. Just to be sure that the way I'm doing is right.

Best regards,
Oleg Romanenko.

Peter M. Groen wrote:
> On Wednesday 21 February 2007 19:49, Oleg Romanenko wrote:
>> Hello,
>>
>> I need to build stock-management application, and one of the forms will
>> contain a QTableView that will have to show more than a hundred thousand
>> rows with ability to edit (rows count will be less if the filters will
>> be used). I need to mark some of the rows with different background
>> color (not an alternate color), and also ability to keep an empty row at
>> the bottom if the user will need to add a new row (fields in the new row
>> has to be in the format column in, for instance if the column is float
>> the field in the empty bottom row has to be float too).
>>
>> How is it possible to achieve? Should I use QTableWidget instead to
>> display the data?
>>
>> Best regards,
>> Oleg Romanenko.
>>
>> --
> 
> Read the part in the documentation about the MVC-pattern and how to use a 
> delegate. This will give you some pointers..

--
 [ signature omitted ] 

Message 4 in thread

Oleg Romanenko wrote:
> Hello,
> 
> I need to build stock-management application, and one of the forms will
> contain a QTableView that will have to show more than a hundred thousand
> rows with ability to edit (rows count will be less if the filters will
> be used). I need to mark some of the rows with different background
> color (not an alternate color), and also ability to keep an empty row at
> the bottom if the user will need to add a new row (fields in the new row
> has to be in the format column in, for instance if the column is float
> the field in the empty bottom row has to be float too).
> 
> How is it possible to achieve? Should I use QTableWidget instead to
> display the data?

For the background color, you can use the data role Qt::BackgroundRole
in your implementation of QAbstractItemModel::data.

hth
M

--
 [ signature omitted ] 

Message 5 in thread

Thanks Martin,

I have tried it, but it did not work for me. :(

Best regards,
Oleg

Martin wrote:
> Oleg Romanenko wrote:
>> Hello,
>>
>> I need to build stock-management application, and one of the forms will
>> contain a QTableView that will have to show more than a hundred thousand
>> rows with ability to edit (rows count will be less if the filters will
>> be used). I need to mark some of the rows with different background
>> color (not an alternate color), and also ability to keep an empty row at
>> the bottom if the user will need to add a new row (fields in the new row
>> has to be in the format column in, for instance if the column is float
>> the field in the empty bottom row has to be float too).
>>
>> How is it possible to achieve? Should I use QTableWidget instead to
>> display the data?
> 
> For the background color, you can use the data role Qt::BackgroundRole
> in your implementation of QAbstractItemModel::data.
> 
> hth
> M

--
 [ signature omitted ] 

Message 6 in thread

On Wednesday 21 February 2007 19:49, Oleg Romanenko wrote:
> Hello,
>
> I need to build stock-management application, and one of the forms will
> contain a QTableView that will have to show more than a hundred thousand
> rows with ability to edit (rows count will be less if the filters will
> be used). I need to mark some of the rows with different background
> color (not an alternate color), and also ability to keep an empty row at
> the bottom if the user will need to add a new row (fields in the new row
> has to be in the format column in, for instance if the column is float
> the field in the empty bottom row has to be float too).
>
> How is it possible to achieve? Should I use QTableWidget instead to
> display the data?
>
> Best regards,
> Oleg Romanenko.

For that many rows I would recommend using the QTableView and a custom model.  
That way you can make the backend implementation and storage most efficient 
for your use case.  Then giving certain rows colors/fonts/etc is as easy as 
modifying the data() function.  Rather then each row having a bool for if it 
should be italic you can have a list of the 10 rows that have italic for 
example.

Here is an example model I wrote that displays one hundred one million rows of 
real data (although not editable in this use case).

http://www.icefox.net/programs/?program=NetflixRecommenderFramework

And of course the required eye candy.
http://www.icefox.net/blogs/explorer.png

-Benjamin Meyer

--
 [ signature omitted ] 

Message 7 in thread

Thanks a lot Benjamin! I am looking into your code right away!

Best regards,
Oleg Romanenko.

Benjamin Meyer wrote:
> On Wednesday 21 February 2007 19:49, Oleg Romanenko wrote:
>> Hello,
>>
>> I need to build stock-management application, and one of the forms will
>> contain a QTableView that will have to show more than a hundred thousand
>> rows with ability to edit (rows count will be less if the filters will
>> be used). I need to mark some of the rows with different background
>> color (not an alternate color), and also ability to keep an empty row at
>> the bottom if the user will need to add a new row (fields in the new row
>> has to be in the format column in, for instance if the column is float
>> the field in the empty bottom row has to be float too).
>>
>> How is it possible to achieve? Should I use QTableWidget instead to
>> display the data?
>>
>> Best regards,
>> Oleg Romanenko.
> 
> For that many rows I would recommend using the QTableView and a custom model.  
> That way you can make the backend implementation and storage most efficient 
> for your use case.  Then giving certain rows colors/fonts/etc is as easy as 
> modifying the data() function.  Rather then each row having a bool for if it 
> should be italic you can have a list of the 10 rows that have italic for 
> example.
> 
> Here is an example model I wrote that displays one hundred one million rows of 
> real data (although not editable in this use case).
> 
> http://www.icefox.net/programs/?program=NetflixRecommenderFramework
> 
> And of course the required eye candy.
> http://www.icefox.net/blogs/explorer.png
> 
> -Benjamin Meyer
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ]