No! I use QTimer for data download.
TxTableModelOrder
::TxTableModelOrder(QTableView *parent
) :{
this->parent = parent;
connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
connect(timer, SIGNAL(timeout()), this, SLOT(timerDone()));
timer->start(1000);
}
TxTableModelOrder::TxTableModelOrder(QTableView *parent) :
QAbstractTableModel(parent)
{
this->parent = parent;
timer = new QTimer(this);
connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
connect(timer, SIGNAL(timeout()), this, SLOT(timerDone()));
timer->start(1000);
}
To copy to clipboard, switch view to plain text mode
Added after 1 8 minutes:
I have fixed this problem. I want somebody who will get this error to know what is wrong.
Look at this code line 13 and 15:
{
if (role == Qt::EditRole) {
QString columnName
= m_Data.
getColumnName(index.
column());
if (columnName == "driver_callsign") {
QString primaryKey
= m_Data.
getRowFieldValue(index.
row(), m_Data.
getKeyField());
QString callsign
= value.
toString();
TxOrder order;
try {
if (callsign.isEmpty()) {
order.clearDriverOnOrder(primaryKey);
} else {
order.setDriverToOrderByCallsign(primaryKey, callsign);
}
} catch (TxException ex) {
qDebug() << ex.getMessage();
}
timer->start(1000);
}
}
return true;
}
bool TxTableModelOrder::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (role == Qt::EditRole) {
QString columnName = m_Data.getColumnName(index.column());
if (columnName == "driver_callsign") {
QString primaryKey = m_Data.getRowFieldValue(index.row(), m_Data.getKeyField());
QString callsign = value.toString();
TxOrder order;
try {
if (callsign.isEmpty()) {
order.clearDriverOnOrder(primaryKey);
} else {
order.setDriverToOrderByCallsign(primaryKey, callsign);
}
} catch (TxException ex) {
qDebug() << ex.getMessage();
}
timer->start(1000);
}
}
return true;
}
To copy to clipboard, switch view to plain text mode
There are http sync requests to server on these lines. That means we wait till server sends response, but QTableView can not wait when user decided to doubleclick in other cell and app crash.
Use async request in setData - this is fix for my problem.
Bookmarks