Results 1 to 17 of 17

Thread: How to use the object name of push button from one class to another??

  1. #1
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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???
    Last edited by Gokulnathvc; 21st March 2011 at 08:08.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to use the object name of push button from one class to another??

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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???

  4. #4
    Join Date
    Nov 2010
    Posts
    20
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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 ? :

    Qt Code:
    1. DialogB::DialogB(const QString &objectName, QWidget *parent) :
    2. QDialog(parent)
    3. {
    4. /* ... Do whatever you want with objectName */
    5. blah->setObjectName(objectName);
    6. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to use the object name of push button from one class to another??

    Quote Originally Posted by Gokulnathvc View Post
    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.
    ... 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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???
    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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....

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.

  12. #12
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #14
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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??

  15. #15
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use the object name of push button from one class to another??

    this is c++-basic. of course is it possible!

  16. #16
    Join Date
    Nov 2010
    Posts
    20
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  17. #17
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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.

Similar Threads

  1. Action using Push Button ?
    By steve.bush in forum Newbie
    Replies: 7
    Last Post: 25th February 2016, 15:36
  2. Push Button with image?
    By steve.bush in forum Newbie
    Replies: 10
    Last Post: 18th March 2011, 06:48
  3. Hareware Push Button
    By mickeyk191 in forum Newbie
    Replies: 2
    Last Post: 26th January 2010, 12:41
  4. shape of push button
    By Seema Rao in forum Qt Programming
    Replies: 23
    Last Post: 2nd April 2008, 01:05
  5. Push Button problem!!
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2006, 16:31

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.