Re: How to use the object name of push button from one class to another??
In VC++ we may use IDOK in resource.h. which denotes the ok button. But how to use the name of the push button from one dialog to another??
Added after 1 26 minutes:
How to use the push button object name in the other dialog???
Re: How to use the object name of push button from one class to another??
Quote:
In VC++ we may use IDOK in resource.h.
This has nothing to do with VS (which is an IDE) but with MFC which is a GUI kit, just like Qt is.
Although it is possible to mix Qt and MFC, I don't really think this is what you are after.
Based on your question, I am not sure YOU know what you are after either.
Maybe if you explain what it is you are trying to do we can give you a shove in the right direction.
Re: How to use the object name of push button from one class to another??
How can i use the object name of the push button that is in a say Dialog A ... to use the push button object name of the Dialog A in Dialog B???
Re: How to use the object name of push button from one class to another??
Maybe can you pass a const-reference to your Dialog B constructor, and then use it for your PushButton ? :
Code:
{
/* ... Do whatever you want with objectName */
blah->setObjectName(objectName);
}
Re: How to use the object name of push button from one class to another??
Quote:
Originally Posted by
Gokulnathvc
How can i use the object name of the push button that is in a say Dialog A
You can query the object name using QObject::objectName property and store it in some variable.
Quote:
... to use the push button object name of the Dialog A in Dialog B???
You can use value from the variable that contains the object name stored there in the previous step.
Re: How to use the object name of push button from one class to another??
Quote:
How can i use the object name of the push button that is in a say Dialog A ... to use the push button object name of the Dialog A in Dialog B???
When I ask what it is you want to achieve I mean in terms of functionality, not implementation.
Your question suggests you are on a wrong way to implement something.
But what is that "something"?
If you explain what you need to have working, we might help you implement it the right way.
Re: How to use the object name of push button from one class to another??
No actually, Am having the push button A in Dialog A, i want to call push button A in Dialog B....
Re: How to use the object name of push button from one class to another??
And how did you want to achieve that using object name?
Re: How to use the object name of push button from one class to another??
Not exactly, I need to use that push button name or object name, How to refer it??? please help me
Re: How to use the object name of push button from one class to another??
I have no idea what you want, sorry. And trying to pull this information out of you has so far proven impossible. Maybe someone else understands what you're trying to do. Investing in a couple of proper English lessons might be a wise thing to do as you're apparently having trouble communicating.
Re: How to use the object name of push button from one class to another??
I want to use the name of the push button in Dialog B which push button is originally present in Dialog A.
For instance, if a function fn() is in Dialog A, if we want to use it, then we may create the object for that Dialog A class in Dialog B then, we will call. Likewise, how to call the push button from Dialog A in Dialog B.
Re: How to use the object name of push button from one class to another??
then you need to pass a pointer to the object, not the object name.
Re: How to use the object name of push button from one class to another??
By the way, your "issue" is purely of C++ nature and not Qt.
Re: How to use the object name of push button from one class to another??
Is it possible to pass a pointer to the object in QT??
Re: How to use the object name of push button from one class to another??
this is c++-basic. of course is it possible!
Re: How to use the object name of push button from one class to another??
You should maybe read a C++ book or tutorial before trying to use Qt
Re: How to use the object name of push button from one class to another??
The "name of pushbutton" in a typical Qt dialog is a member of a private UI class instance (if Designer built it) or a private member of the dialog class itself (if you hand-coded). In either case C++ scope rules prohibit access to the push button object variable from outside the class (please notice I said accessed not called: you call methods not objects). Nothing here is Qt-specific, just standard C++.
The code that is executed when a user presses the push button is a standard C++ method, usually, but not necessarily, in the dialog class that contains the button. This code can be called from outside the class if it is declared public and not private or protected. Nothing here is Qt-specific, just standard C++.
In QDialog derived classes the accept() (roughly equivalent to pushing the OK button), reject() (roughly equivalent to pushing the Cancel button) and done() methods are all accessible from outside by default.
If you could be bothered to answer the repeated queries about what you are trying to achieve, rather than how, perhaps more specific guidance could be given.