Cant use ui on others functions
-
mainwindow.cpp
http://wklej.to/3KynT
mainwindow.h
http://wklej.to/l7UAN
why that code didnt work?
@void pizda::aha()
{
MainWindow xd;
xd.ui->label->setText("aha");
}@
no errors
how can i resolve this? -
The mainwindow in pida::aha() is constructed in that method, you set the text and then it is destructed again, so it is never visible. It is most not the one you are actually showing in your main method.
You could try to pass the Mainwindow pointer into the method or turn the MainWindow into a singleton or store it in a global variable (not nice) and access that in your method.
-
yea, its work, but what i how i can do it when i want write it on class?
like
@class pizda
{
void aha(Ui::MainWindow* ok)
{
ok->label->setText("aha");
}
};@
that isnt work -
refresh