Results 1 to 4 of 4

Thread: Ui interface and its connected implementation

  1. #1
    Join Date
    Jan 2010
    Posts
    37
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Ui interface and its connected implementation

    Hi!!

    I am having a serious problem with QT designing. When i draw widgets on the form in say xyz.ui file. these widgets don't get connected to the code i write in xyz.h file and xyz.cpp file.

    The widgets which are drawn on the form have no use. When in implementation file i initialise QPushButton *button = new QPushButton(tr("New"));
    a new button appears on the form with the old button drawns on the xyz.ui file in the back. Why does this happen? Do i have to link the individual button interface to its code in implementation file explicitly? If yes then how? if no then what to do??
    Plz guide!!
    Last edited by Yayati.Ekbote; 4th February 2010 at 09:58. Reason: i cannot add screenshots of the ui interface form if i have to show people the output.

  2. The following user says thank you to Yayati.Ekbote for this useful post:

    mkkguru (8th February 2010)

  3. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Ui interface and its connected implementation

    Why You create new widgets "manually" in implementation code ?
    Please show Yours code (h and cpp files).

  4. The following user says thank you to Lesiok for this useful post:

    Yayati.Ekbote (2nd March 2010)

  5. #3
    Join Date
    Feb 2010
    Location
    Hyderabad, India
    Posts
    15
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Ui interface and its connected implementation

    Are you sure, you have used the connect method properly to connect the widgets in your UI to the slots defined in your cpp file
    Check
    http://qt.nokia.com/doc/4.6/qobject.html#connect-2

    In case you do not wish to explicitly connect, take a look at

    http://qt.nokia.com/doc/4.6/qmetaobj...ectSlotsByName

    Hope it helps

  6. The following user says thank you to mrvk for this useful post:

    Yayati.Ekbote (2nd March 2010)

  7. #4
    Join Date
    Oct 2007
    Posts
    78
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Ui interface and its connected implementation

    Quote Originally Posted by Yayati.Ekbote View Post
    Hi!!

    I am having a serious problem with QT designing. When i draw widgets on the form in say xyz.ui file. these widgets don't get connected to the code i write in xyz.h file and xyz.cpp file.

    The widgets which are drawn on the form have no use. When in implementation file i initialise QPushButton *button = new QPushButton(tr("New"));
    a new button appears on the form with the old button drawns on the xyz.ui file in the back. Why does this happen? Do i have to link the individual button interface to its code in implementation file explicitly? If yes then how? if no then what to do??
    Plz guide!!
    If you are loading the ui file and using it as a widget try the following:

    Qt Code:
    1. QPushButton *button = qFindChild<QPushButton *>(QUiLoader::load("xyz.ui"), "name_of_your_button_in_your_ui_file");
    To copy to clipboard, switch view to plain text mode 
    Edit: Of course the return widget from QUiLoader is going to be needed elsewhere and should be saved and only referenced instead of single called and thrown away in the example.

    Bob
    Last edited by coderbob; 4th February 2010 at 13:41.

  8. The following user says thank you to coderbob for this useful post:

    Yayati.Ekbote (2nd March 2010)

Similar Threads

  1. Is internet connected
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2009, 21:22
  2. Disconnect slot when another is being connected
    By holst in forum Qt Programming
    Replies: 4
    Last Post: 8th September 2009, 09:49
  3. Connected client tree
    By cooler123 in forum Qt Programming
    Replies: 7
    Last Post: 13th July 2009, 20:49
  4. The application with connected units.
    By kuzulis in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2009, 23:54
  5. how can i know how many slots connected to a signal?
    By yj_yulin in forum Qt Programming
    Replies: 6
    Last Post: 1st December 2008, 10:24

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.