View Full Version : How to call my QPushButton from another class ?
probine
27th March 2006, 12:10
I have two classes: A and B.
Class A contains all the user interface (QPushButtons, QTextEdit, ...), while class B contains the implementation and functionallity of the program.
How can B for example change the text of a button in class A ?
Kapil
27th March 2006, 12:22
I have two classes: A and B.
Class A contains all the user interface (QPushButtons, QTextEdit, ...), while class B contains the implementation and functionallity of the program.
How can B for example change the text of a button in class A ?
Create an object of A in class B and then through that object call the
obj->pushButton->text("Button Name");
it would do it for you.
probine
27th March 2006, 12:36
The object that I have to create:
in class B:
______________
A* a;
a->btn->setText("hello");
_________________
Post more code please !!!
Kapil
27th March 2006, 12:41
The object that I have to create:
in class B:
______________
A* a;
a->btn->setText("hello");
_________________
Post more code please !!!
In class B: -
A *a_obj = new A;
a_obj->button->text("hello");
also dont forget to include the A in your code.. You will have to convert it into header file (A.h) and then include it in you B.cpp...
This would do it for you...
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.