I have a QWidget B which is contained inside a QWidget A. QWidget A has a QLabel. I have some data inside QWidget B, which I want to set as the value of the QLabel. How can something like this be done?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First of all, if I understand your topic correctly, you have your own derivations of QWidget for A and B.
The clean solution to your problem is that B emits a signal, like
newLabelText(QString text);.Then, A provides a slot
setLabelText(QString text);. You connect the signal to the slot and you are done.In this solution, only one entity needs to know both A and B to perform the Signal/Slot-Connection, while A and B do not have to know each other, or mangle with each other.