Results 1 to 10 of 10

Thread: Dialog opens twice

  1. #1
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Dialog opens twice

    Hi !

    If user clicked a button then a dialog will pop up.

    The problem is that the dialog pops up twice, one after another. That means, after user give an input and click OK, the same dialog appears and asks user again.

    However, other buttons which do open the same dialog have no such a problem.

    The dialog class inherits QDialog.

    Does converting to Qt4 play role in this case ? Because the problem button is already located on ui file which has been converted through Qt4's designer and the other buttons are still on Qt3's ui files.

    Thx in advance.

  2. #2
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dialog opens twice

    show us the code snippet : how u are poping the new dialog ..
    "Behind every great fortune lies a crime" - Balzac

  3. #3
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Dialog opens twice

    On the problem button (defined in cpp file):

    Qt Code:
    1. void
    2. SensitivitiesWidget::on_SingleFunctionChooser_clicked()
    3. {
    4. const CCopasiObject * pObject =
    5. CCopasiSelectionDialog::getObjectSingle(this,
    6. CCopasiSimpleSelectionTree::NumericValues);
    7. }
    To copy to clipboard, switch view to plain text mode 

    On one of other buttons (defined in ui.h file):

    Qt Code:
    1. void Curve2DWidget::buttonPressedX()
    2. {
    3. if (!mpModel) return;
    4.  
    5. mpObjectX = CCopasiSelectionDialog::getObjectSingle(this,
    6. CCopasiSimpleSelectionTree::NumericValues);
    7. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Dialog opens twice

    If I go back to the old Qt3's ui file, the problem does not come up.

    I believe this is about converting problem to Qt4.

    However, I did do some works on interface only in converting progress

  5. #5
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Dialog opens twice

    No, the problem does not really correlated to converting process.

    If I changed the name of button, the problem will disappear. The window will pop up once.

    However, I don't still understand why changing the button name simply solve the problem. I have checked whether the name is used somewhere else in the code, but everything looks like OK.

    Any idea ???

  6. #6
    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: Dialog opens twice

    Do you have a connect() statement related to the on_SingleFunctionChooser_clicked() slot?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Dialog opens twice

    Yes, I have.

    The connect() statement is automatically generated from SensitivitiesWidget.ui file. That means it is in ui_SensitivitiesWidget.h.

    The slot itself has been declared in SensitivitiesWidget.h and defined in SensitivitiesWidget.cpp.

  8. #8
    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: Dialog opens twice

    Then you have two connections to the same slot. If you name a slot in a form of on_objectName_signalSignature() it will be automatically connected to the signalSignature() signal from objectName. Either remove the connection in Designer or change the slot name.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    May 2008
    Posts
    24
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Dialog opens twice

    Aha ! I see !

    The on_objectName_signalSignature() slot is automatically connected to the signalSignature() signal from objectName. This is done by default. Also, I should not spend an extra effort to make signal-slot connection, even in Qt Designer. Just declare it in header file and define in implementation one.

    However, why am I not able to see the 'second' connect() statement ? Is the statement hidden from us ?

  10. #10
    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: Dialog opens twice

    Quote Originally Posted by ulmly View Post
    The on_objectName_signalSignature() slot is automatically connected to the signalSignature() signal from objectName. This is done by default. Also, I should not spend an extra effort to make signal-slot connection, even in Qt Designer. Just declare it in header file and define in implementation one.
    It's better to make the connection graphically and name the slot in a way that it gives more information about what it does instead of a vague information when it is triggered.

    However, why am I not able to see the 'second' connect() statement ? Is the statement hidden from us ?
    The second connection is done by
    QMetaObject::connectSlotsByName() that is called from setupUi() in the file generated by uic from your Designer form.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Issue with Modelless dialog on Mac
    By Satyanarayana Chebrolu in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 10:10
  2. Dialog is not closing
    By manmohan in forum Newbie
    Replies: 5
    Last Post: 1st December 2008, 17:04
  3. Replies: 9
    Last Post: 13th August 2008, 18:07
  4. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  5. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 17:48

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.