Solved Hidden and Window
-
I want to make switching between windows ..
Made it through
void BlitzerMainWindow::on_pushButton_clicked() { hide(); homewindow = new HomeWindow(this, ui->textEdit_2->toPlainText()); homewindow->show(); }
But after * Hidden *
applications disappeared completely with TaskBar
And a new window didn’t appear there either.So here is what to do?
I want to create a new window so that it is in the taskbar -
Hi and welcome
Adding to @SGaist,
What is HomeWindow inherited from ?If its just a QWidget, then when you give it a parent it will get inserted into the parent and not act as a window
homewindow = new HomeWindow(this<<<< parent , ui->textEdit_2->toPlainText());
-
Hi and welcome to devnet,
This type of question has been asked pretty frequently these past few weeks. Please take the time to search the forum.
As for your problem, you are closing the one and only window of your application which by default means that the application has ended.
-
Hi and welcome
Adding to @SGaist,
What is HomeWindow inherited from ?If its just a QWidget, then when you give it a parent it will get inserted into the parent and not act as a window
homewindow = new HomeWindow(this<<<< parent , ui->textEdit_2->toPlainText());
-
I want to open a new window
See task bar this
How to open a new window normally .. -
Like we already said and as already suggested in other threads: do not hide the main window before opening your new widget.
And as @mrjj wrote, if you make your new widget a child of BlizterWindow, it will get hidden with it and thus the application will end so don't do that.
-
Sorry))
I'm just too dumb and new to c ++ and qt
Thanks for helping
I replace this
homewindow = new HomeWindow(this, ui->textEdit_2->toPlainText());
On
homewindow = new HomeWindow(nullptr, ui->textEdit_2->toPlainText());
hide(); //i left this, since I wanted to hide the old window
big thx @mrjj
-
In that case, please take the time to learn the C++ basics before taking on more complex tasks. It will save you a lot of time in the future.
The same goes for Qt, don't hesitate to go through the documentation. There are lots of tutorials and examples that can help you get started.
-
Hi
No need to be sorry. Just ask good questions with
lots of details and the current code and we try to help. :)However, as @SGaist says, using the Qt framework does demand some c++
skills as extending a class use inheritance and overrides of virtual functions
so its really up the hill if such concepts are unfamiliar.Regarding this parent thing.
When you do give them a parent to a Widget, (to put it in another Widget)
it will then own the widget.
That means it will auto delete its children when its self is deleted.
This is unlike plain c++ where you must always remember to clean up allocated objects.
So this is a must-read.
https://doc.qt.io/qt-5/objecttrees.htmlAs not to delete something manually when its owned by another Widget/window
as that often gives a crash.Now back to your window.
Every time you click the button , you create a new window.
So that will actually leak memory since it doesn't have a parent. ( to be a window)
You can do
homewindow ->setAttribute(Qt::WA_DeleteOnClose);
to have it delete itself when close so its cleaned up.