Hello,
First of all sorry for the ugly syntax/style of my code...
Well so I am creating my small GUI, I have a main window (no problem here), and a secondary window (pops up for connecting to database). to connect to the db i have a connection class (a QPhushButton) wich takes the input of 4 QLineEdits. The problem is : I can create my connection class/Line Edits if i set their parent as the Main window but not if I pass my connectionForm class (which inherit from QWidget since it is a window )
I do not know if I expressed myself well so here is the code :
First the connectionForm constructor :
connectionForm
::connectionForm(QWidget *parent
) :QWidget(parent
), ui
(new Ui
::connectionForm){
ui->setupUi(this);
QLineEdit hostLine
(&this
);
// error here, end of my post for error message QLineEdit userLine
(&this
);
// error here, end of my post for error message QLineEdit passLine
(&this
);
// error here, end of my post for error message QLineEdit dbLine
(&this
);
// error here, end of my post for error message connection_class co1 (&this); // error here, end of my post for error message
//The code continues but has no bug
connectionForm::connectionForm(QWidget *parent) :QWidget(parent), ui(new Ui::connectionForm)
{
ui->setupUi(this);
QLineEdit hostLine (&this); // error here, end of my post for error message
QLineEdit userLine (&this); // error here, end of my post for error message
QLineEdit passLine (&this); // error here, end of my post for error message
QLineEdit dbLine (&this); // error here, end of my post for error message
connection_class co1 (&this); // error here, end of my post for error message
//The code continues but has no bug
To copy to clipboard, switch view to plain text mode
Here the connectionForm.h
#include <QWidget>
#include "connection.h"
namespace Ui {
class connectionForm;
}
class connectionForm
: public QWidget{
Q_OBJECT
public:
explicit connectionForm
(QWidget *parent
= 0);
~connectionForm();
private:
void setConnectionGeomConnec
(QWidget *co
);
void setLineEditGeom
(QWidget *leg,
int x,
int y,
int h,
int w
);
Ui::connectionForm *ui;
connection_class co1 ();
};
#include <QWidget>
#include "connection.h"
namespace Ui {
class connectionForm;
}
class connectionForm : public QWidget
{
Q_OBJECT
public:
explicit connectionForm(QWidget *parent = 0);
~connectionForm();
private:
void setConnectionGeomConnec(QWidget *co);
void setLineEditGeom(QWidget *leg, int x, int y, int h, int w);
Ui::connectionForm *ui;
QLineEdit hostLine;
QLineEdit userLine;
QLineEdit passLine;
QLineEdit dbLine;
connection_class co1 ();
};
To copy to clipboard, switch view to plain text mode
and finally, the constructor of connection_class .
connection_class (QWidget *parent, QLineEdit *host,QLineEdit *user,QLineEdit *pass,QLineEdit *dbn);
To copy to clipboard, switch view to plain text mode
The error message precisely is :
cannot take the adress of a rvalue of type 'connectionForm'
I understand it means that I used a wrong type for initialisation but why ? Since connectionForm inherits from QWidget...
Bookmarks