tags:

views:

40

answers:

1

I am going to write an application that uses QT4 (with C++ or python it isnt important in that moment). One of functionality is "Showing all items in database".

One item has a Title, author, description and photo (constant size)

And there could be very many items. Let's say 400. There won't be enough space to show'em all at once time. One row will have 200px, so i need at most 4 for once time.

How to paginate them? I have no idea. I can use limit and offset in SQL queries, but how to tell window: "that's 5th page"?

Any solutions?

+1  A: 

First off, you normally do not want to use any manually set pixel widths in any GUI application, if you do, your toolkit sucks (or you must work in game development).

Second off: be more specific.

You'll need to define "page" for your application, namely what a page should be in its context. I assume it is breaking a list of items into separate pages. Normally this is done by using one of the view classes (e.g. QListView or QTableView) to take care of much of the legwork: it's called a scrollbar (not to mention the collapsing folders concept from file managers). Another method is splitting the information across several tab pages (QTabWidget), where each page displays a view of some sort (Perhaps QTextView or one of the M/V or Item view classes).

Same thing can also be done using your own widget stack and some other widget to manipulate the currently displayed page. This is basically how the option dialogs in the TeamSpeak 3 client and most KDE apps work; it's also how wizards with back/next buttons work in concept. I suggest you take a look at this config dialog example

Normally what you want is a view with a scrollbar and or some form of collapsing related entries into categorised information. If you just want to display a list of pages where each page is X entries: use a tab widget or stacked widget.

TerryP
i specified 200px to tell that it is impossible to have all items at once.I'll check tab widget and stacked widget.
matiit
Ok, i read. But i will have to creating dynamic number of pages. There won't be one page, i will have to create all pages and via qstackedwidget show only one. Do i understand it good?
matiit
I'm not sure if I understand your comment good lol. You can dynamically add/remove any number of pages to a QStackedWidget, up to memory exhaustion. If you've an idea of how many pages you will need in advance, you can pre-allocate the pages for the stacked widget before populating them with the data. (E.g. # of entries / # of page = # of pages to construct).You haven't said to much about the apps particulars, so I can't be very specific.
TerryP
Ok, so i get the idea.
matiit