Originally Posted by
unix7777
Doing so the button is enabled even i don't select a row.
I use updateClientTable() to update the content of TableView after every manipulation (search, add, delete etc.)
What i understand is that on this way the SLOT is always called!
OK... now bear with me... just trying to find a way to debug this...
Change the declaration of setBool to:
void setBool(const QModelIndex& current, const QModelIndex& previous);
void setBool(const QModelIndex& current, const QModelIndex& previous);
To copy to clipboard, switch view to plain text mode
change the definition to:
void Clients::setBool(const QModelIndex& current, const QModelIndex& previous) {
qDebug() << "At setBool" << current << previous << ui->tableView_clients->currentIndex();
ui->pushButton_select->setEnabled(ui->tableView_clients->currentIndex().isValid());
}
void Clients::setBool(const QModelIndex& current, const QModelIndex& previous) {
qDebug() << "At setBool" << current << previous << ui->tableView_clients->currentIndex();
ui->pushButton_select->setEnabled(ui->tableView_clients->currentIndex().isValid());
}
To copy to clipboard, switch view to plain text mode
and change the Clients constructor to:
Clients
::Clients(QWidget *parent
) : ui(new Ui::Clients)
{
ui->setupUi(this);
updateClientTable();
setBool
(ui
->tableView_clients
->currentIndex
(),
QModelIndex());
}
Clients::Clients(QWidget *parent) :
QDialog(parent),
ui(new Ui::Clients)
{
ui->setupUi(this);
updateClientTable();
setBool(ui->tableView_clients->currentIndex(), QModelIndex());
connect(ui->tableView_clients->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(setBool(QModelIndex,QModelIndex)));
}
To copy to clipboard, switch view to plain text mode
and let’s see if we can spot anything unexpected going on in the debug output. Watch to see when setBool is called and that the previous and current indices are what you would expect.
I know you said you have a problem with seeing the debug output because of difficulty connecting to your SQLite file under QtCreator. I can’t help you there, but it’s probably worth finding a way to make it work.
Bookmarks