LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   QT - Spreadsheet like tabular widget (https://www.linuxquestions.org/questions/programming-9/qt-spreadsheet-like-tabular-widget-4175466733/)

devnull10 06-20-2013 07:13 AM

QT - Spreadsheet like tabular widget
 
Hi,
I am writing an app in QT and I need to accept user input in the form of a table. The number of columns will be fixed (determined at runtime) however the number of rows (whilst initially can be set to a fixed number) will vary. So the user might want to enter 100 rows or 1000 rows of data, either by pasting in, or typing.
Now I know I can (when pasting) work out how many extra lines there are and add that many rows, however it would be a more flexible solution to have a solution similar to excel where the scrollbar knows whether there is data in later cells and sizes accordingly (i.e. if you have only a few rows populated it gets the look and feel of having just one page however if you have thousands then the scrollbar sizes accordingly).
So I am looking for some form of spreadsheet like widget which would achieve this. Ideally I would like to avoid having to pre-create a large number of blank rows (because it might be the user needs to use several hundred thousand).
I can add a "add rows" button but again this is a bit messy - I want the user not to have to worry about adding additional rows etc.
Does anyone have any suggestions?

dugan 06-20-2013 09:39 AM

Use a QTableWidget. Or a QAbstractTableModel with a QTableView if a QTableWidget isn't flexible enough.


All times are GMT -5. The time now is 03:13 PM.