I want to open a new form, close it an reopen it.
However, when I reopen it, all changed stuff still is there (like text in a label or something like that). Now I am not really concerned with these trivial visual ... leftovers, but more with the inner working. Will a timer keep running after i close this window? Keep updating labels with pictures? (I don't really want that by default)
So what I want is : I open a new form, after that form is closed, it will be destroyed an renewed. This would result in a fresh screen ready to start.
I know it is not that crazy. In VB.NET it looks like this:
// the initialization :
Private WithEvents _frmLogging As frmLogging
Private WithEvents _frmLogging As frmLogging
To copy to clipboard, switch view to plain text mode
//opening the form, by pressing a button or something
_frmLogging = New frmLogging
_frmLogging.Show()
_frmLogging = New frmLogging
_frmLogging.Show()
To copy to clipboard, switch view to plain text mode
//deleting it when it is closed :
Private Sub CatchClosingLog(sender As Object, e As EventArgs) Handles _frmLogging.FormClosed
_frmLogging.Dispose()
_frmLogging = Nothing
End Sub
Private Sub CatchClosingLog(sender As Object, e As EventArgs) Handles _frmLogging.FormClosed
_frmLogging.Dispose()
_frmLogging = Nothing
End Sub
To copy to clipboard, switch view to plain text mode
I want to replicate this in Qt . frmMain is my Qmainwindow and I want to open frmTest which is represented by oTestFrame.
void frmMain::on_btnOpenNew_clicked()
{
oTestFrame.show();
__hook(&frmTest::FormClosed, &oTestFrame, &frmMain::OnCloseSecondTry); //Here I create an event. This allows me to run code in [I]frmMain[/I] after [I]frmTest[/I] is closed
}
void frmMain::on_btnOpenNew_clicked()
{
oTestFrame.show();
__hook(&frmTest::FormClosed, &oTestFrame, &frmMain::OnCloseSecondTry); //Here I create an event. This allows me to run code in [I]frmMain[/I] after [I]frmTest[/I] is closed
}
To copy to clipboard, switch view to plain text mode
When oTestFrame is closed, OnCloseSecondTry is executed. That is were it all goes wrong.
void frmMain::OnCloseSecondTry()
{
__unhook(&frmTest::FormClosed,& oTestFrame, &frmMain::OnCloseSecondTry); //unhook event, just good practice, I don't really think it will matter after the object is destroyed (Am I wrong?)
oTestFrame.~frmTest();
frmTest oTemp;
oTestFrame = &oTemp;
}
void frmMain::OnCloseSecondTry()
{
__unhook(&frmTest::FormClosed,& oTestFrame, &frmMain::OnCloseSecondTry); //unhook event, just good practice, I don't really think it will matter after the object is destroyed (Am I wrong?)
oTestFrame.~frmTest();
frmTest oTemp;
oTestFrame = &oTemp;
}
To copy to clipboard, switch view to plain text mode
The important variables are declared in frmMain.h :
...
private:
frmTest oTestFrame;
void OnCloseSecondTry();
...
...
private:
frmTest oTestFrame;
void OnCloseSecondTry();
...
To copy to clipboard, switch view to plain text mode
I destroy oTestFrame. But I can not insert a fresh frmTest object in oTestFrame.
I read somewhere you could not store a Qwidget in a Qwidget. Is that true?
How can i get this to work? Any suggestions welcome :P
Bookmarks