Answer the question
In order to leave comments, you need to log in
How to use QSqlQuery in your class constructor?
I create a player class:
#include "player.h"
Player::Player(int id = 0)
{
query.prepare("SELECT * FROM player WHERE id=:id");
query.bindValue(":id",id);
query.exec();
}
QString Player::getName()
{
return name;
}
Player::~Player()
{
}
#ifndef PLAYER_H
#define PLAYER_H
#include <QSqlQuery>
class Player
{
public:
Player(int id);
~Player();
QString getName();
private:
QString name;
QSqlQuery query;
};
#endif // PLAYER_H
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question