Hello,
So I have two forms in my project: MainWindow and Options Form (OptForm; QWidget
);
Now, I create (simply dragging to a form) a QPushButton
in MainWindow to open OptForm, and passing in variables, which OptForm can change.
void MainWindow::openOpt() //Slot; QPushButton calls(?) it
{
OptForm w (this->variable1,this->variable2, this);
w.show();
}
OptForm constructor is:
OptForm::OptForm(bool & variable1, bool & variable2, QWidget *parent)
: QWidget (parent)
{
variable1Pointer = &variable1;
variable2Pointer = &variable2;
ui.setupUi(this);
}
options.h has:
class OptForm : public QWidget
{
Q_OBJECT
public:
OptForm(bool & variable1, bool & variable2, QWidget *parent)
//Pointers for encrypt and verbose
bool * variable1Pointer;
bool * variable2Pointer;
public slots:
void change_variable1();
void change_variable2();
private:
Ui::OptForm ui;
};
Now, void change_variable1();
and void change_variable2();
changes booleans to true
or false
.
Now, in these functions I have a line
this->*variable1Pointer = true;
And I get compiler error:
'((OptForm*)this)->OptForm::variable1Pointer' cannot be used as a member pointer, since it is of type 'bool*'
How do I get things right? (FIXED, THANKS)
Other thing what I need, is to let MainWindow know, when OptForm has closed, to check if options have changed. So, where should I place this code? In openOpt
, or create a slot, which will be executed(?), when OptForm closes? How can I send signal to MainWindow then?
Thanks in advance. (I guess I have messed things up quite much)
Ok, compiler error fixed, but now, when I press that button window appers and closes immediately :/