Hi again
I hit the problem with making one class' object available in the entire application.
The object is created every time I try to establish a new connection with db, and after success it is sent to the core class (core - one which controls main UI). By that I have an access to the connection data which I want to have usable many times in different ways.
So I send a pointer to an object(the object itself is created in the UI which is destroyed right after connection being established) and from that moment I have connection data available from the core-level of my application.
Hope that is explained as simple as possible.
Now, I tried to solve this using QSharedPointer, but I think I did not catch an idea which comes with this class.
But before I ask you to help with making this understandable to me, I would like to ask whether there is claver and simpler solution for that.
The class which contains data looks like below
class ConnectionData
: public QObject{
Q_OBJECT
public:
explicit ConnectionData
(QObject *parent
= 0);
short int getPort() const;
private:
pass,
host,
connectionName;
short int port;
};
class ConnectionData : public QObject
{
Q_OBJECT
public:
explicit ConnectionData(QObject *parent = 0);
void set(QString u,QString p,QString h,QString c,short int port);
QString getUser() const;
QString getPass() const;
QString getHost() const;
QString getConnectionName() const;
short int getPort() const;
private:
QString user,
pass,
host,
connectionName;
short int port;
};
To copy to clipboard, switch view to plain text mode
so it's not so big, maybe passing by value ?
Bookmarks