Results 1 to 9 of 9

Thread: Program crashes when radioButton selected

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2013
    Posts
    58
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows
    Thanks
    26

    Question Re: Program crashes when radioButton selected

    Done some modifying on code... to no avail though

    Basically I need to check which radio button selected
    The Problem -> RadioButton in main dialog Class(Window)
    -> the Check statement is in a different class("label class" within Window/dialog)

    Created signals & slots as:
    Qt Code:
    1. Dialog::Dialog(QWidget *parent) :
    2. QDialog(parent),
    3. ui(new Ui::Dialog)
    4. {
    5. ui->setupUi(this);
    6. connect(ui->radioButton_1, SIGNAL(n1_Selected()), my_qlabel, SLOT(my_qlabel::HandleN1()));
    7. connect(ui->radioButton_2, SIGNAL(n2_Selected()), my_qlabel, SLOT(my_qlabel::HandleN2()));
    8. ...
    9. }
    To copy to clipboard, switch view to plain text mode 

    in dialog:
    Qt Code:
    1. void Dialog::on_radioButton_1_clicked()
    2. {
    3. emit n1_Selected();
    4. }
    5.  
    6. void Dialog::on_radioButton_2_clicked()
    7. {
    8. emit n2_Selected();
    9. }
    To copy to clipboard, switch view to plain text mode 

    my slots in sub class (label class)
    .h
    Qt Code:
    1. private slots:
    2. void HandleN1();
    3. void HandleN2();
    To copy to clipboard, switch view to plain text mode 
    .cpp
    Qt Code:
    1. void my_qlabel::HandleN1()
    2. {
    3. //calculations
    4. }
    5.  
    6. void my_qlabel::HandleN2()
    7. {
    8. //diff-calculations
    9. }
    To copy to clipboard, switch view to plain text mode 

    Above not working!
    Where am I going wrong?
    How do I fix it?

    Thanks
    Last edited by ebsaith; 13th June 2013 at 09:18. Reason: updated contents

  2. #2
    Join Date
    Feb 2013
    Location
    India
    Posts
    153
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    27
    Thanked 18 Times in 18 Posts

    Default Re: Program crashes when radioButton selected

    As i have seen some issues in your code implementation.

    Qt Code:
    1. // Make sure [B]my_qlabel[/B] is is initialized before you use.
    2.  
    3. my_qlabel = new QLabel(this); // my_qlabel is not initialized in your code
    4.  
    5. // ui->radioButton_1 should be 'this' because you are emitting a signal from dialog class
    6. connect(ui->radioButton_1, SIGNAL(n1_Selected()), my_qlabel, SLOT(HandleN1()));
    7.  
    8. // ui->radioButton_2 should be 'this' because you are emitting a signal from dialog class
    9. connect(ui->radioButton_2, SIGNAL(n2_Selected()), my_qlabel, SLOT(HandleN2()));
    To copy to clipboard, switch view to plain text mode 


    Try changing these things...

    CHEERS..!!

  3. The following user says thank you to karankumar1609 for this useful post:

    ebsaith (13th June 2013)

Similar Threads

  1. Program crashes on 64-bit systems
    By WereWind in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2013, 10:29
  2. Program crashes on OS X Lion
    By fyodor in forum Newbie
    Replies: 1
    Last Post: 31st October 2011, 06:18
  3. Program crashes
    By Fallen_ in forum Qt Programming
    Replies: 49
    Last Post: 20th September 2010, 01:41
  4. Program crashes (SIGSEGV)
    By Voldemort in forum Qt Programming
    Replies: 47
    Last Post: 21st May 2007, 20:09
  5. Replies: 5
    Last Post: 27th May 2006, 13:44

Tags for this Thread

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.