Results 1 to 6 of 6

Thread: QDialog show method's wierd problem on signal slot mechanism.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17
    Thanked 90 Times in 88 Posts

    Default Re: QDialog show method's wierd problem on signal slot mechanism.

    Hi!

    Please use the forums-code-tags! In the advanced edit there is a "#"-button!

    I think that one of your slots is called on first show, because the value has changed between initialization and then.

    Your code is not compilable as is.. so you will have to track down the source of the problem yourself. Remove the Show Hide Workaround. remove all connects - comment them out. And uncomment them one by one.

    Maybe it has to do with values you set in Designer? A plain QDoubleSpinboxes ValueChanged doesn't fire on creation..

    Qt Code:
    1. #include <QApplication>
    2. #include <QDebug>
    3. #include <QtGui>
    4. #include <QtCore>
    5.  
    6. class MainForm : public QDialog
    7. { Q_OBJECT
    8. public:
    9. MainForm() {
    10. spinbox = new QDoubleSpinBox(this);
    11. connect(spinbox,SIGNAL(valueChanged(double)),this,SLOT(SpinBoxValueChanged(double)));
    12. }
    13. protected slots:
    14. void SpinBoxValueChanged(double value) {
    15. qDebug() << "Value changed";
    16. }
    17. private:
    18. QDoubleSpinBox* spinbox;
    19. };
    20.  
    21. int main(int argc, char *argv[])
    22. {
    23. QApplication app(argc, argv);
    24. app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
    25.  
    26. MainForm form;
    27. form.setGeometry(100,100,800,600);
    28. form.show();
    29.  
    30. return app.exec();
    31. }
    32.  
    33. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    Good luck!

    Johannes

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

    umituzun84 (25th March 2010)

  3. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17
    Thanked 90 Times in 88 Posts

    Default Re: QDialog show method's wierd problem on signal slot mechanism.

    Aah..!! You do it yourself:

    Qt Code:
    1. void SettingWindow::showEvent(QShowEvent *event)
    2. {
    3. updateAxisValues();
    4. updateCurveValues();
    5. updateCurveSettings();
    6. QDialog::showEvent(event);
    7. }
    To copy to clipboard, switch view to plain text mode 

    On first show.. this is called.. Thus updating all values.. Thus all ValueChanged-Slots are called..

    If you want some other behaviour, you will have to change this :->

    Johannes

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

    umituzun84 (25th March 2010)

  5. #3
    Join Date
    Jan 2010
    Location
    Ankara - TURKEY
    Posts
    30
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    13
    Thanked 1 Time in 1 Post

    Default Re: QDialog show method's wierd problem on signal slot mechanism.

    Hi Johannes,

    I have realized the explicit value change on controls in my update functions How dummy I am! Thanks so much for your helps. I solved this problem by kind of this codes;

    Qt Code:
    1. ui.comboBoxCurveName->blockSignals(true); // For stop signal creation
    2. ui.comboBoxCurveName->clear();
    3.  
    4. QwtPlotItemList plotItemList = graph->itemList(QwtPlotItem::Rtti_PlotCurve);
    5.  
    6. for(QwtPlotItemIterator it = plotItemList.begin(); it != plotItemList.end(); it++)
    7. {
    8. QwtPlotCurve *curve = (QwtPlotCurve*)(*it);
    9. ui.comboBoxCurveName->addItem(curve->title().text());
    10. }
    11. ui.comboBoxCurveName->blockSignals(false); // For start signal creation
    To copy to clipboard, switch view to plain text mode 

    So there is no signal while I am manipulating controls attributes.

    Thanks again.
    Regards.

Similar Threads

  1. When should I use signal/slot mechanism
    By Bryku in forum Newbie
    Replies: 3
    Last Post: 10th February 2010, 22:24
  2. slow signal-slot-mechanism
    By blm in forum Qt Programming
    Replies: 11
    Last Post: 28th October 2008, 17:10
  3. can a single statement work in signal/slot mechanism
    By salmanmanekia in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2008, 08:24
  4. The threaded signal/slot mechanism
    By xbtl in forum Newbie
    Replies: 1
    Last Post: 30th March 2008, 00:07
  5. Replies: 4
    Last Post: 23rd January 2006, 16:51

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.