You could also declare the slot with a default parameter like this:
void add_changes
(QString table_name
= "town");
void add_changes(QString table_name = "town");
To copy to clipboard, switch view to plain text mode
Then you'd establish the connection without a parameter:
connect(ok_button,SIGNAL(clicked()),this,SLOT(add_changes()));
connect(ok_button,SIGNAL(clicked()),this,SLOT(add_changes()));
To copy to clipboard, switch view to plain text mode
Whenever the button is clicked, the default parameter "town" will be used. If you want to call the function with another parameter in code, just pass so:
add_changes("foo");
add_changes("foo");
To copy to clipboard, switch view to plain text mode
I guess you would have to subclass QSqlRelationalDelegate and reimplement setEditorData():
void MySqlRelationalDelegate
::setEditorData(QWidget* editor,
const QModelIndex & index
) const {
if (QComboBox* combo
= dynamic_cast<QComboBox
*>
(editor
)) {
proxy->setSourceModel(combo->model());
// combo's current model must be reparented, otherwise QComboBox::setModel() will delete it
combo->model()->setParent(proxy);
combo->setModel(proxy);
combo->model()->sort(0);
}
}
void MySqlRelationalDelegate::setEditorData(QWidget* editor, const QModelIndex & index) const
{
QSqlRelationalDelegate::setEditorData(editor, index);
if (QComboBox* combo = dynamic_cast<QComboBox*>(editor))
{
QSortFilterProxyModel* proxy = new QSortFilterProxyModel(combo);
proxy->setSourceModel(combo->model());
// combo's current model must be reparented, otherwise QComboBox::setModel() will delete it
combo->model()->setParent(proxy);
combo->setModel(proxy);
combo->model()->sort(0);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks