Results 1 to 3 of 3

Thread: Qt Creator - signals/slots problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt Creator - signals/slots problem

    Hey everyone,

    I'm using QtCreator to design my project. I need to send a datagram every 5 seconds out of a udpSocket. What i'm trying to do is this: When a user clicks the Enable button, it starts a timer - every 5 seconds the datagram is sent out the updSocket.

    Here's my code -

    Qt Code:
    1. void jaus::startBroadcasting()
    2. {
    3. connect(timer, SIGNAL(timeout()), this, SLOT(sendDatagram()));
    4. ui->enableButton->setText("Disable");
    5. ui->enableButton->setEnabled(false);
    6. timer->start(5000);
    7. }
    8.  
    9. void jaus::sendDatagram()
    10. {
    11. QByteArray message = "Hello.";
    12. udpSocket->writeDatagram(message, QHostAddress::LocalHost, 9000);
    13. }
    To copy to clipboard, switch view to plain text mode 

    I have the Enable button anchored to the startBroadcasting() slot. But when I click the button, the program blows up -- it doesn't do that when I take out the connect command and the timer->start() command.

    Thanks for any help
    Last edited by ctote; 17th February 2010 at 22:01.

Similar Threads

  1. Replies: 2
    Last Post: 28th August 2009, 07:12
  2. Signals and Slots Problem
    By GenericProdigy in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2009, 09:06
  3. Signals And Slots problem
    By ldiamond in forum Newbie
    Replies: 7
    Last Post: 23rd March 2008, 00:11
  4. Problem using SIGNALS/SLOTS
    By JimDaniel in forum Qt Programming
    Replies: 5
    Last Post: 10th September 2007, 04:59
  5. Problem with signals and slots
    By conexion2000 in forum Qt Programming
    Replies: 2
    Last Post: 23rd March 2006, 10:20

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.