Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

TableWidgets



  • I've been using Pascal, almost exclusively, since 1986. Thirty-three years later, I'm 99% sure that I'd like to try my hand at C++. I've tried a few of the other IDEs and really like the look and feel of Qt.

    But my deal is this: I'm use to data-aware components on a form and am not so sure that I can get the same functionality from a Tablewidget as I wld get from a DBGrid. Youtube has a few tutorials that demonstrate tablewidgets holding data, but all of them get that data from line edits and the like that won't make it to the grid until, say, the user presses a save button. Everything has to be done on the grid...the tablewidget. This is a must. And that includes some kind of mechanism for adding new rows, such as arrowing down past the last record on the grid for a new row to be added.

    If someone can tell me this is possible, then I'll be at 100%.

    Thank you, Forum.


  • Moderators

    In Qt data is handled by a model derived from QAbstractItemModel. This class has a general data() and setData() methods that do most of the heavy lifting.

    The view is a separate thing and there are several classes for different models. For tables there's the QTableWidget, which is a basic, generic, entry level view and a QTableView, which is a lower level but allows for greater control and is easier to tweak performance wise.

    Both of these are customizable to great extent. I'm not sure what you mean by "everything must be done on the grid", but the example you gave with adding a row via arrow key should be as easy as handling key press event in the view and calling insertRows() on the model.



  • I've been using Pascal, almost exclusively, since 1986. Thirty-three years later, I'm 99% sure that I'd like to try my hand at C++.

    Off topic, but why?


Log in to reply