PDA

View Full Version : using the parent-pointer



doktorn
30th August 2007, 12:15
Hello.
This is probably more a C++ question than a pure QT, but anyway...

What I want is simply to adress a QObject, lets say the textEdit of the parent widget.
I want to get some respons from the server which is not connected to the Ui in any other way. I've looked in my c++-books for parent and parent-calls, but haven't found anything...

I eather get a:
server.cpp:15: error: insufficient contextual information to determine type
if i try to user parent.
or if I try to user the parent->
it tells me that its not a pointer type.



#include "server.h"
#include "client.h"

Server::Server(QObject *parent)
: QTcpServer(parent)
{
}

void Server::incomingConnection(int socketId)
{
//here I want some kind of parent call...

}

marcel
30th August 2007, 14:35
You can access the parent of a QObject very simple via QObject::parent(). It returns a QObject.

Regards

doktorn
31st August 2007, 10:18
OK. I'll try that. I Like the Smiley there.

Thanks!

marcel
31st August 2007, 14:45
Probably there is a lousy text parser that doesn't know it shouldn't add smileys in inside Qt classes names.

Regards

Gopala Krishna
31st August 2007, 18:51
Probably there is a lousy text parser that doesn't know it shouldn't add smileys in inside Qt classes names.

Regards

I complained against this sometime before and the forum admins fixed this while parsing text in CODE block. :) But they haven't fixed it for all cases yet :(
A better fix may be to convert text to smiley only if the text corresponding to smiley is whitespace separated.

Sorry for being offtopic.

marcel
31st August 2007, 18:59
Well, apparently it knows to parse entities in the form "ClassName::method()" because the links to Qt classes work. maybe because they are contained within QTCLASS -- /QTCLASS tags.

It shouldn't parse what is between code -- /code tags at all.

Regards