Results 1 to 4 of 4

Thread: How to call my QPushButton from another class ?

  1. #1
    Join Date
    Jan 2006
    Posts
    185
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to call my QPushButton from another class ?

    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 ?

  2. #2
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to call my QPushButton from another class ?

    Quote Originally Posted by probine
    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.

  3. #3
    Join Date
    Jan 2006
    Posts
    185
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to call my QPushButton from another class ?

    The object that I have to create:

    in class B:
    ______________
    A* a;
    a->btn->setText("hello");
    _________________

    Post more code please !!!

  4. #4
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to call my QPushButton from another class ?

    Quote Originally Posted by probine
    The object that I have to create:

    in class B:
    ______________
    A* a;
    a->btn->setText("hello");
    _________________

    Post more code please !!!
    In class B: -
    [HTML]
    A *a_obj = new A;
    a_obj->button->text("hello");
    [/HTML]

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

Similar Threads

  1. Qpushbutton
    By iamhere in forum Qt Programming
    Replies: 5
    Last Post: 15th October 2008, 04:40
  2. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  3. How to use Signal through direct connection
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2007, 07:07
  4. Replies: 3
    Last Post: 16th May 2007, 11:07
  5. virtual overloaded functions and base class function call...
    By nouknouk in forum General Programming
    Replies: 7
    Last Post: 11th March 2006, 21:26

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
  •  
Qt is a trademark of The Qt Company.