having access to members and functions of a class from its subclass
hi. i have 2 classes A and B. B is subclass into the A. B needs to access to the A members and functions. how could i do this in Qt?
Re: having access to members and functions of a class from its subclass
This has nothing to do with Qt. If you are writing in C++, it is a C++ question and you should look up C++ inheritance.
If what you are asking is this kind of subclassing:
Code:
class B
{
// ...
};
class A : public B
{
// ...
};
and you mean B needs to know about methods that are defined only in A, then how is this supposed to work? If you create an instance of class B and try to cast it to "A" and use A methods, your code will probably crash when you try to call A methods because an instance of B is not an instance of A even if you force the code to treat it that way.
Maybe you should show some of your code where you are trying to do what you want, because the way I understand your question it doesn't make any sense.
Re: having access to members and functions of a class from its subclass
Quote:
Originally Posted by
d_stranz
This has nothing to do with Qt. If you are writing in C++, it is a C++ question and you should look up C++ inheritance.
If what you are asking is this kind of subclassing:
Code:
class B
{
// ...
};
class A : public B
{
// ...
};
and you mean B needs to know about methods that are defined only in A, then how is this supposed to work? If you create an instance of class B and try to cast it to "A" and use A methods, your code will probably crash when you try to call A methods because an instance of B is not an instance of A even if you force the code to treat it that way.
Maybe you should show some of your code where you are trying to do what you want, because the way I understand your question it doesn't make any sense.
thanks so much d_stranz, class A is like this
class A : public QThread
if A can be a QWidget and a QThread too (class A : public QWidget and QThread), the problem can be solved.
thanks a lot help me
Re: having access to members and functions of a class from its subclass
Quote:
Originally Posted by
QJak
thanks so much d_stranz, class A is like this
class A : public QThread
if A can be a QWidget and a QThread too (class A : public QWidget and QThread), the problem can be solved.
thanks a lot help me
Error. Qt GUI objects can only live in the main thread. You have a conceptual problem.
Re: having access to members and functions of a class from its subclass
thanks
I need to do 3 works toghether in the same time:
1- first thread does processing on gived data and showing results with GUI
2- second thread does logging (saving above data into a file)
3- third thread does waiting every 10 second and then sending a byte to GUI of the first thread for showing
please help me to do this work
thanks
Re: having access to members and functions of a class from its subclass
I think you only need two threads: main (with GUI) and worker. Worker process data, logs them to the file and sends data to GUI with signals and slots. Sending data to GUI is activated with QTimer::timeout signal with 10s period.
Re: having access to members and functions of a class from its subclass
thanks
before i did this by using signal and slot. but when i send a signal to two slots, the slots not working in paralell procces and first one of these slots works and after finishing this slot, the other slot starts. but i need the two slots work paralel (like thread)
Re: having access to members and functions of a class from its subclass
How do slots work in parallel if they are in one thread? If they must work in parallel then they must be in separate threads.