The function in my self developed small Qt class library does exactly that by
foreach
(QLineEdit* widget, findChildren<qLineEdit
*>
()){
if( !firsteditablewidget) firsteditablewidget = widget;
modified = true;
widget->clear();
}
foreach(ecTextEdit* widget, findChildren<ecTextEdit*>())
{
widget->clear();
}
foreach
(QTableView* widget, findChildren<QTableView
*>
()){
if( abstractmodel )
{
if( abstractmodel->inherits( "QSqlQueryModel"))
{
model->clear();
.....
foreach(QLineEdit* widget, findChildren<qLineEdit*>())
{
if( !firsteditablewidget) firsteditablewidget = widget;
modified = true;
widget->clear();
}
foreach(ecTextEdit* widget, findChildren<ecTextEdit*>())
{
widget->clear();
}
foreach(QTableView* widget, findChildren<QTableView*>())
{
QAbstractItemModel * abstractmodel = widget->model();
if( abstractmodel )
{
if( abstractmodel->inherits( "QSqlQueryModel"))
{
QSqlQueryModel *model = (QSqlQueryModel *)abstractmodel;
model->clear();
.....
To copy to clipboard, switch view to plain text mode
All I wanted to know if there is a better way to achieve this...
Bookmarks