T
T
timao2015-03-26 15:43:43
Qt
timao, 2015-03-26 15:43:43

How to get rid of downcast in GUI?

There is a window Window, on it on different tabs there are about fifty widgets: QLineEdit, QDateEdit and QComboBox, or rather their own derived classes.
The essence of the Window window:
Open the window -> select query from mysql -> fill widgets
Press the Save button -> update query in mysql -> close the window
In order not to write logic for each individual widget, I want to have something like QMap, where the first field is a column mysql tables. All this to populate widgets, compare with the original value (QWidget::setProperty), collect update requests in a more centralized way. And don't duplicate the code.
I haven't written a GUI much in my life, but I don't want to start a project with a downcast. Thank you for your attention.
PS Who is not familiar with Qt:
QLineEdit, QDateEdit and QComboBox are descendants of QWidget, all of which are library GUI widget classes.
QMap - analogue of std::map

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2015-03-26
@timao

have something like QMap where the first field is a mysql table column.

and the second field is a pointer to a generic interface, let's call it IUpdate, implemented by concrete classes that know how to work with concrete widget classes. Or directly by the widget classes themselves.

A
Armenian Radio, 2015-03-26
@gbg

Generate your fifty widgets along with the request, who forbids you? It's just that the program needs to "know" a little more about the data structure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question