Results 1 to 5 of 5

Thread: Problem with SpinBox signals and slots

  1. #1
    Join Date
    Dec 2007
    Posts
    32
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem with SpinBox signals and slots

    Hello and good day.

    Id like to seek help regarding a dialog that doesnt obey its signals and slots connections.
    I have this code for the dialog connecting different spinboxes,

    Qt Code:
    1. connect(mnhSpinBox, SIGNAL(valueChanged(int)), mxhSpinBox, SLOT(setValue(int)));
    2. connect(mnsSpinBox, SIGNAL(valueChanged(int)), mxsSpinBox, SLOT(setValue(int)));
    To copy to clipboard, switch view to plain text mode 

    Now when i build my program, it doesnt fulfill its intended purpose which is to update the value of the other spin box.

    BUT, when I connect the signals and slots via the designer it works. Now I have built other dialogs but I didnt encounter any problems like this.

    Any help would be greatly appreciated.

    P.S.: Ive read the FAQ about the signals and slots but it didnt help me.

  2. #2
    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: Problem with SpinBox signals and slots

    Could you provide a minimal compilable example which reproduces the problem?
    J-P Nurmi

  3. #3
    Join Date
    Dec 2007
    Posts
    32
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with SpinBox signals and slots

    Ok. I forgot to tell that I am running QT4 for Windows.
    I uploaded two versions,
    - in the folder sample contains the .ui file that has no signals set in the designer
    - int the folder sample2 contains the .ui file that has signals and slots set in the designer

    Thank you for looking into them..
    Attached Files Attached Files

  4. #4
    Join Date
    Apr 2008
    Location
    Pavlodar, Kazakhstan
    Posts
    22
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem with SpinBox signals and slots

    Your code does not use isolateDialog at all. The dialog instantiation is not correct. You should not create QDialog and set Ui::isolateDialog for it. You are to create isolateDialog instead. So remove the following lines:

    Qt Code:
    1. Ui::isolateDialog ui;
    2. QDialog *dialog = new QDialog;
    3. ui.setupUi(dialog);
    To copy to clipboard, switch view to plain text mode 

    And just add

    Qt Code:
    1. isolateDialog *dialog = new isolateDialog;
    To copy to clipboard, switch view to plain text mode 

    You also have a mistake in your dialog .cpp file.

    Qt Code:
    1. connect(minsatSpinBox, SIGNAL(valueChanged(int)), minhueSpinBox, SLOT(setValue(int)));
    To copy to clipboard, switch view to plain text mode 
    must be replaced with
    Qt Code:
    1. connect(minsatSpinBox, SIGNAL(valueChanged(int)), maxsatSpinBox, SLOT(setValue(int)));
    To copy to clipboard, switch view to plain text mode 

    The reason why your code works when you make connections in QDesigner is that QDesigner connects signals and slots in the constructor of Ui::isolateDialog.
    Last edited by mitro; 1st May 2008 at 11:42.

  5. #5
    Join Date
    Dec 2007
    Posts
    32
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with SpinBox signals and slots

    Ok that was very informative.

    Thank you very much for the help. I appreciate it.

Similar Threads

  1. Signals And Slots problem
    By ldiamond in forum Newbie
    Replies: 7
    Last Post: 23rd March 2008, 00:11
  2. Memory Problem with SIGNALS and SLOTS
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2007, 20:39
  3. Nested signals and slots
    By vishva in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2006, 09:47
  4. Problem with signals and slots
    By conexion2000 in forum Qt Programming
    Replies: 2
    Last Post: 23rd March 2006, 10:20
  5. Problem with Signals and Slots
    By Kapil in forum Newbie
    Replies: 11
    Last Post: 15th February 2006, 11: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.