Questions tagged [qtsql]

Questions related to QtSQl Module, a collection of Qt classes that work with various relational database management systems.

Provides a driver layer, SQL API layer, and a user interface layer for SQL databases.

238 questions
3
votes
1 answer

Is it possible to use just one Qt module, just like a 3rd party dll?

I'd been looking for a DB access library for C++ which will run under Windows. I tried SOCI: does not compile SQLAPI++: not free Next option was to use Qt's DB access module, QtSql. Is it possible only to use QtSql without importing or linking any…
Hayri Uğur Koltuk
  • 2,970
  • 4
  • 31
  • 60
3
votes
1 answer

Parameter count mismatch in Qtsql

I'm trying to insert data into a QtSql database, but I keep getting the error: "Parameter count mismatch" What could be what I'm doing wrong? #include int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); qDebug() <<…
Program-Me-Rev
  • 6,184
  • 18
  • 58
  • 142
3
votes
1 answer

Query result to QML

What is the best way to return the result of a SQL query to QML? I have this function that executes a query: bool Storage::setQuery(QString query) { QSqlQuery qsqlQuery; bool success = qsqlQuery.exec(query); qDebug() << "Error setQuery"…
simon
  • 1,180
  • 3
  • 12
  • 33
3
votes
2 answers

QSqlQuery: get prepared statement string before execution

For testing purposes, I'm trying to get the prepared statement string out of a QSqlQuery object before actually running it. I have checked lastQuery() and executedQuery() methods, but none of them work. void foo(QSqlQuery& q) { QString statement…
Antonio Pérez
  • 6,702
  • 4
  • 36
  • 61
3
votes
1 answer

QT Sql and Threads

This is my situation, requests are made through the browser to my application. Each request is handled by a different thread and in some cases these requests include INSERT, UPDATE, DELETE, in a sqlite database. What I do not understand is how to…
bartbrat
  • 53
  • 1
  • 5
3
votes
1 answer

Qt : Cannot open include file: 'QtSql': No such file or directory

It might be a duplicate question, but the founded answers haven't solved my problem. I am trying to create a client server application in QT where the client sends to the server a String message code and the server has to connect to the sql server…
laura
  • 2,085
  • 13
  • 36
  • 68
3
votes
1 answer

Qt sql query failed

query->prepare("INSERT INTO businessweek (id, source, date, headline, body) VALUES (NULL, ?, ?, ?, ?)"); query->bindValue(1, "source"); query->bindValue(2, "date"); query->bindValue(3, "headline"); query->bindValue(4, "body"); if (query->exec()) { …
Dewsworld
  • 13,367
  • 23
  • 68
  • 104
2
votes
2 answers

QtSql cannot execute a query

#include #include #include int main(int argc, char* argv[]) { QApplication app(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setHostName("test"); db.setDatabaseName("firma"); …
Dewsworld
  • 13,367
  • 23
  • 68
  • 104
2
votes
1 answer

QSqlQuery::exec: database not open, PyQt

i'm trying to output data from sqlite database. I did it like in PyQt's examples, but it does not work. It seems that the database is opened, but the code is giving errors, that it does not. Could you tell me why and how i can fix…
SaulTigh
  • 913
  • 2
  • 14
  • 27
2
votes
2 answers

Qt and databases save and open them

I have an app that handles multiple databases which the users edits and i would also like it to open them from a specified path (like i get the path using QFileDialog). Also I saw that it saves the databases files where the executable file is but is…
Andrew
  • 165
  • 4
  • 16
2
votes
1 answer

parameter count mismatch in parameterized query

I am using quite a lot of parameterized queries in my code for performance reasons. In short, some of them work, some don't. I initialize the query during construction of my database wrapper like this: QString querystring = QString("SELECT somevalue…
arne
  • 4,514
  • 1
  • 28
  • 47
2
votes
1 answer

Updating a record in QSqlTableModel

I am trying to update a record and i have this: tableModel->select(); QModelIndex index = ui.tableView->currentIndex(); QString sqlQuery = QString("UPDATE %1 SET firstname=:firstname, lastname=:lastname, country=:country, city=:city WHERE…
Gandalf
  • 1
  • 29
  • 94
  • 165
2
votes
1 answer

Easiest way to create a table with lots of columns in QT with SQL?

I'm going to create a table with these column names. QStringList column_names =…
euraad
  • 2,467
  • 5
  • 30
  • 51
2
votes
1 answer

QtSql connect to multiple databases

I am having a problem with Python 3.7 PyQt5 QtSql. I am trying to have multiple MSSQL databases connected, but cannot figure how to do it. I have the following function to connect: from PyQt5 import QtSql def connectDb(database_name): …
user12918986
2
votes
1 answer

How to refresh the list of items in the combobox delegate which represents the data of a QSqlRelationalTablemodel

I've recently examined an example from Chapter 15 of “Rapid GUI Programming with Python and Qt” by Mark Summerfield which presents the use of SQL Database TableView modelling. In this original example, I found a little dysfunctionality which…
ROB
  • 23
  • 6
1 2
3
15 16