Results 1 to 11 of 11

Thread: Problem with MyQDialog

  1. #1
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Problem with MyQDialog

    I wrote a function, called by a pushbutton cliocked signal, like this one:

    Qt Code:
    1. void frmMain::addElement()
    2. myDialog dlg (this);
    3. QString result;
    4. if ( dlg.exec() == QDialog::Accepted ) {
    5. result = "pippo";
    6. }
    7. return result;
    To copy to clipboard, switch view to plain text mode 

    When I press on OK pushbutton the dialog don't close itself but It's called/opened another time and when I press on OK pushbutton the second time the dialog close well.
    Why?

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with MyQDialog

    and what is the code for myDialog ??

    How have u handled the slots for OK ?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with MyQDialog

    Maybe the slot is called twice?

  4. #4
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with MyQDialog

    Make sure the clicked() signal of the button is connected to the accept() slot of the form.

  5. #5
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Problem with MyQDialog

    Quote Originally Posted by jacek View Post
    Maybe the slot is called twice?
    no, I've only one connect between pusbutton clicked signal and my slot addElement.

  6. #6
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Problem with MyQDialog

    I've only one connect in myDialog constructor:

    connect (myOkButton, SIGNAL(clicked()), frmMain, SLOT(addElement()) );

  7. #7
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Problem with MyQDialog

    Quote Originally Posted by stevey View Post
    Make sure the clicked() signal of the button is connected to the accept() slot of the form.
    Do you think that I need of :
    connect ( pbOkButtonMyDialog, SIGNAL(clicked()), myDialog, SLOT(accept())); ?

  8. #8
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with MyQDialog

    Do you think that I need of :
    connect ( pbOkButtonMyDialog, SIGNAL(clicked()), myDialog, SLOT(accept())); ?
    yesss,,,
    u need to connect the clicked signal of the button to the accept slot of the myDialog.
    This connection is better written in the constructor of the myDialog

  9. #9
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with MyQDialog

    Do you think that I need of :
    connect ( pbOkButtonMyDialog, SIGNAL(clicked()), myDialog, SLOT(accept())); ?
    Didn't I already say this?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with MyQDialog

    Quote Originally Posted by fruzzo View Post
    I've only one connect in myDialog constructor:

    connect (myOkButton, SIGNAL(clicked()), frmMain, SLOT(addElement()) );
    Does the dialog open when you comment out this line? Maybe you invoke exec() somewhere in that dialog's code?

  11. #11
    Join Date
    Dec 2007
    Posts
    119
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Problem with MyQDialog

    Problem solved I leave some connection from designer so by code I duplicate it!
    thanx to all!

Similar Threads

  1. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  2. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  3. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  4. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.