[Qt-interest] Submitting changes in a QTableView
Lars Amsel
lars.amsel at signalion.com
Fri Jul 10 08:37:04 CEST 2009
Malyushytsky, Alex wrote:
> I don't see why you would not subclass.
First, I don't like subclassing for such simple tasks, because I end up with a
big bunch of classes like QTableviewWithSubmitMethod. Second (more practical
reason) the Qt integration into Eclipse which I am using does not support
custom widget in the Designer, so I would have to use the external designer or
no designer at all.
> But the key is that these are slots and not just an ordinary functions.
> You can connect them to any signal.
> The fact that they are protected is irrelevant when we are talking about signal/slot implementation.
> You still can connect any signal to any slot, it does not matter if it is protected, private or public.
Oh, I didn't know that, but will keep it in mind. That really solves my problem.
class MainWindow : public QMainWindow {
...
signals:
commitTableData(QWidget* widget);
}
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags) :
QMainWindow(parent, flags) {
...
connect(
this, SIGNAL(commitTableData(QWidget*)),
ui.table, SLOT(commitData(QWidget*)));
}
void MainWindow::on_actionAnalyse_triggered() {
//first commit dangling edits
QWidget* widget = ui.tableData->focusWidget();
if (widget != NULL) {
emit commitTableData(widget);
}
//continue analysis
}
Still, this looks like a hack to me, but the previous solution (sending
QKeyEvent with return key) was even more a hack.
Thanks
Lars
More information about the Qt-interest-old
mailing list