QDialog setVisible(false) crash
-
@Sasha said:
void chatDialog::closeEvent(QCloseEvent *event)
...
this->setVisible(false);Is is this one that makes it crash ?
You have this on
this->setAttribute(Qt::WA_DeleteOnClose);If you disable it for test, it will still crash ?
Also, you have
delete ui; in chatDialog::~chatDialog()
Is that ok? Normally it handled by ownership
but you might have done something special.I will try later to compile when near compiler :)
-
Hi
Here it crashes in
thread->terminate();
in destructorSince you do not new it. (its a comment)
// thread=new QThread;If I remove that, no crashes. But I did have to some stuff as I did not have the UI file.
-
@mrjj said:
Since you do not new it. (its a comment)
// thread=new QThread;If I remove that, no crashes. But I did have to some stuff as I did not have the UI file.
Hi, it was problem with this line of code:
this->setAttribute(Qt::WA_DeleteOnClose);
But now my destructor does not work even if i close application. But thanks, u helped me a lot, i am now and i learning hard to get better.
Once time, thanks a lot. -
Hi
If you destructor is not being called, then you can just do it your
self in the main windows destructor .
Also,
Please check where you new the chatDialog that you give it mainwin as parent
like
.. x= new chatDialog (this)and not just chatDialog() which gives it no parent and hence no one will delete it when application closes.
-
Hi, chatDialog is created by login dialog. And when login is success i create chatDialog and hide loginDialog. If i set parent for chatDialog then chatDialog will be hidden too. So i cant set parent for chatDialog...
-
@Sasha
Ok. I see.In Login Dialog
new chatDialog (this)
will give ChatDialog Login as parent, so
its
new chatDialog (this->parent())
To give it main as parent.
(Login->parent()) -
@mrjj said:
In Login Dialog
new chatDialog (this)
will give ChatDialog Login as parent, so
its
new chatDialog (this->parent())
To give it main as parent.It says:
/home/guza/Chat/chatdialog.cpp:6: error: invalid conversion from 'QObject*' to 'QWidget*' [-fpermissive]
ui(new Ui::chatDialog)
Login is mainwindow.. -
Ahh
So login is the mainwinow.
Well sorry then :)
When you hide mainwin it hides its children.
So you need to keep the ChatDialog pointer around and delete from
Logins destructor. -
Can u help me with thread and QTcpSocket. I have a thread class, and in that chass i have QTcpSocket object.
When i write QByteArray with that QTcpSocket i got this message:
Cannot create children for a parent that is in a different thread. (Parent is QNativeSocketEngine(0x7fa104003280), parent's thread is myThread(0xaf5e30), current thread is QThread(0xaf1210)
In thread i have connect (DirectConnect) sockets signal readyRead and disconnects with threads slots readyRead and disconnects, and in parent of this thread i connect(AutoConnection) thread signal sendMessage with parent slots getMessage.
But i got that error when i call in thread socket->write(array); -
@Sasha
Hi you better make a new thread for that as it is a complex problem.
http://stackoverflow.com/questions/6900994/qobject-cannot-create-children-for-a-parent-that-is-in-a-different-threadI never really used the network object so other here are far better to help you with this than me.
-
-
@Sasha
You are very welcome :)