Results 1 to 20 of 41

Thread: closing a dialog

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    31
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: closing a dialog

    Quote Originally Posted by axeljaeger View Post
    Either create m_webapp inside m_setapp or have m_setapp emit a signal and connect that to the show-slot of m_webapp.
    I'll have to read up on that

    I want the widget to not create the web app utill its called for e.g.
    Qt Code:
    1. void mum::web() {
    2. if ( ! m_webapp ) {
    3. m_webapp = new webapp(NULL);
    4. }
    5. m_webapp->show();
    6. }
    To copy to clipboard, switch view to plain text mode 
    How do I destroy m_webapp after closing it?

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: closing a dialog

    Just delete it in the destructor. (once in the lifetime of your application).
    It's nice to be important but it's more important to be nice.

  3. #3
    Join Date
    Oct 2009
    Posts
    31
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: closing a dialog

    delete it like this?
    Qt Code:
    1. webapp::~webapp(){
    2. delete this;
    3. }
    To copy to clipboard, switch view to plain text mode 
    doesnt seem to delete m_webapp

    also emitting the signal and connecting to it
    what am I doing wrong?

    Qt Code:
    1. m_setapp = new SetApp(NULL);
    2. connect(m_setapp, SIGNAL(showeb()), this SLOT(web()));
    3. }
    4. void mum::web() {
    5. m_webapp->show();
    6. }
    7. ..................
    8. connect( pushButton_node, SIGNAL( clicked() ), this, SLOT( node() ) );
    9. }
    10. void SetApp::node() {
    11. emit showeb(); //this pushbutton code work
    To copy to clipboard, switch view to plain text mode 
    or can I do I connect to a slot in a different class?
    Last edited by chrisb123; 25th October 2009 at 13:51.

  4. #4
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: closing a dialog

    delete this in a destructor is an infinite recursion.

    delete calls the destructor. It is basically calling a method within itself. This will not work.


    Regarding your signal & slots connection: What does not work? Do you get any warnings in the console? Do all connect-statements return true?
    It's nice to be important but it's more important to be nice.

  5. #5
    Join Date
    Oct 2009
    Posts
    31
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: closing a dialog

    Quote Originally Posted by axeljaeger View Post
    delete this in a destructor is an infinite recursion.

    delete calls the destructor. It is basically calling a method within itself. This will not work.
    closing it does not destroy it, it just hides it

    Regarding your signal & slots connection: What does not work? Do you get any warnings in the console? Do all connect-statements return true?
    syntax error, i missed the , after this
    it works as expected
    Last edited by chrisb123; 25th October 2009 at 14:19.

  6. #6
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: closing a dialog

    Quote Originally Posted by chrisb123 View Post
    closing it does not destroy it, it just hides it
    What do you want to tell me?
    It's nice to be important but it's more important to be nice.

  7. #7
    Join Date
    Oct 2009
    Posts
    31
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: closing a dialog

    Think I've worked it out
    I want the plasmoid to display a seperate dialog and QWebView when requested.
    I dont want the QWebView to be always loaded but hidden

    So currently it does the following, From my understadning

    1. when the plasmoid starts it creates the constructor which just creates the dialog
    2. when i select the item to show the dialog I use showEvent to create a QWebView and display the page.
    3. When I close the dialog I use closeEvent to delete the QWebView

    What can I use as profiling software?

  8. #8
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: closing a dialog

    Why on earth do you want to create the webView in the showEvent and destroy it when it gets closed? Just do it like anyone else: Create it in the constructor let it Qt destroy when necessary. Dont try to be too clever, keep it simple stupid, trust Qt.

    You can use either valgrind or oprofile for profiling. But if there is already need for profiling, then your computer has a problem.
    It's nice to be important but it's more important to be nice.

Similar Threads

  1. Closing a dialog using a button
    By srohit24 in forum Qt Programming
    Replies: 5
    Last Post: 21st July 2009, 05:57
  2. Issue with Modelless dialog on Mac
    By Satyanarayana Chebrolu in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 10:10
  3. Dialog is not closing
    By manmohan in forum Newbie
    Replies: 5
    Last Post: 1st December 2008, 17:04
  4. Replies: 9
    Last Post: 13th August 2008, 18:07
  5. closing dialog in hidden main Widget
    By Lele in forum Qt Programming
    Replies: 3
    Last Post: 6th December 2006, 10:35

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.