I wasn't clear enough in my description. The QSqlQueryModel is derived to MyModel:
{
active_row = -1; // no row will be colored
}
MyModel::MyModel(QObject *parent)
:QSqlQueryModel(parent)
{
active_row = -1; // no row will be colored
}
To copy to clipboard, switch view to plain text mode
So, I have nothing to do with setting the color in the application code. All that must be done is to set the active row.
void MyModel::setActiveRow(int row) // called from slot doubleClick
{
active_row = row;
}
void MyModel::setActiveRow(int row) // called from slot doubleClick
{
active_row = row;
}
To copy to clipboard, switch view to plain text mode
The workaround I found meanwhile, is to implement a function, that emits the protected signal "layoutChanged":
void MyModel::__layoutChanged()
{
emit layoutChanged();
}
void MyModel::__layoutChanged()
{
emit layoutChanged();
}
To copy to clipboard, switch view to plain text mode
I have to call it after calling setActiveRow. That's no clean interface, further on there must be a reason, why the signal is protected.
It works so far, but is there any better solution?
Bookmarks