0
votes

I have a problem with deploying qt application. When i deploy it on my machine (Win 8) QTableView shows normally (columns and rows, header and all) On my machine

but when i try to run it on different pc (Win 7) On another machine

there is nothing in table view not even header for columns and rows, only when i add new row it shows that symbol for new line (*). With application there are libraries in directory: Qt5Core.dll Qt5Widgets.dll Qt5Gui.dll Qt5Sql.dll libgcc_s_dw2-1.dll libstdc++-6.dll libwinpthread-1.dll

I have tried to recompile it (with MinGW) and copying libraries again. But it didn't help.

Some code:

database = QSqlDatabase::addDatabase("QSQLITE");
database.setDatabaseName(QCoreApplication::applicationDirPath() + "/dennik.db");

if(database.open()){
    ui->status->setText("DB is open");
} else {
    qDebug() << "Error while loading database";
}

model = new QSqlTableModel(this);
model->setTable("dennik");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->setSort(0, Qt::AscendingOrder);
model->select();
model->setHeaderData(0, Qt::Horizontal, tr("Datum"));
model->setHeaderData(1, Qt::Horizontal, tr("Prichod1"));
model->setHeaderData(2, Qt::Horizontal, tr("Odchod1"));
model->setHeaderData(3, Qt::Horizontal, tr("Prichod2"));
model->setHeaderData(4, Qt::Horizontal, tr("Odchod2"));
model->setHeaderData(5, Qt::Horizontal, tr("C_HOD"));
model->setHeaderData(6, Qt::Horizontal, tr("OP_HOD"));

connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), this, SLOT(updateOP()));


ui->table->horizontalHeader()->setStretchLastSection(true);
ui->table->setItemDelegateForColumn(0, new DateDelegate(this));
ui->table->setItemDelegateForColumn(1, new TimeDelegate(1, model, this));
ui->table->setItemDelegateForColumn(2, new TimeDelegate(2, model, this));
ui->table->setItemDelegateForColumn(3, new TimeDelegate(3, model, this));
ui->table->setItemDelegateForColumn(4, new TimeDelegate(4, model, this));



ui->table->setModel(model);
ui->table->setColumnWidth(1, 70);
ui->table->setColumnWidth(2, 70);
ui->table->setColumnWidth(3, 70);
ui->table->setColumnWidth(4, 70);
ui->table->setColumnWidth(5, 60);
ui->table->show();

How can I make it work? Maybe another compiler?

1
You need to show some code, or preferably an mcve.G.M.
@G.M. Some code uploadedDávid deiwo

1 Answers

0
votes

So, I found out what was wrong. QSqlTableModel was not able to access sqldrivers directory because they are supposed to be in root of application not in plugins directory. Everything works fine now.