Results 1 to 5 of 5

Thread: QDialog - Calling Main Window Function

  1. #1
    Join Date
    Jun 2007
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QDialog - Calling Main Window Function

    Hi,

    I have a dilaog which opens from MainWindow, After a User Clicks OK, i need to call a function of Dialog How can i do so..?

    Please give some sample code.

  2. #2
    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: QDialog - Calling Main Window Function

    Make a signal-slot connection from the clicked() signal of the button to a custom slot and in that slot call "the function of Dialog". If you make that "function" a slot, you can connect to it directly.

  3. #3
    Join Date
    Jun 2007
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog - Calling Main Window Function

    Sorry i need to call a function of MainWindow on Click on OK Button. Below is code i used

    MyClass my;
    connect(uiconfig.okButton, SIGNAL(clicked()), &my, SLOT(Test()));

    But on click on Button it doesn't goes inside Test function. Please let me know.

    Thanks,

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDialog - Calling Main Window Function

    Quote Originally Posted by Preeteesh View Post
    Qt Code:
    1. {
    2. MyClass my;
    3. connect(uiconfig.okButton, SIGNAL(clicked()), &my, SLOT(Test()));
    4. } // "my" goes out of scope
    To copy to clipboard, switch view to plain text mode 
    Perhaps "my" goes out of scope and no more exists by the time button is clicked. Allocating "my" with keyword new solves the problem.
    J-P Nurmi

  5. #5
    Join Date
    Jun 2007
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog - Calling Main Window Function

    It does worked but it didn't got QTreeWidget empty. Actually I have a QTreeWidget in my MainWindow. I open a Dialog from a file open dialog and then it calls that slot which clears the tree by doing ui.treeWidget->clear(), This exectues but tree still doesn't Gets cleared, how should i do it.

Similar Threads

  1. Replies: 4
    Last Post: 4th June 2007, 13:07
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 07:13
  3. Replies: 4
    Last Post: 10th March 2007, 19:01
  4. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 13:52
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 11:21

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.