Results 1 to 3 of 3

Thread: QTimer - Why this is not working?

  1. #1
    Join Date
    Aug 2009
    Location
    Kolkata
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTimer - Why this is not working?

    Hi,

    I am using QT4 on Fedora 10. I am unable to run a timer event. Please help.
    Attaching my code.

    void MainWindow::test_func()
    {
    QMessageBox::information(this,"Test", "Testing Timer","Hi");
    }

    void MainWindow:n_actionSpatial_Connection_triggered()
    {
    QTimer *timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(test_fun c()));
    timer->start(1000);
    }

    Basically I want to start a timer on a click event and the timer should call a function till the timer is stopped.

    Thanks in advance...
    Prasenjit
    Kolkata, India

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTimer - Why this is not working?

    are you sure that test_func is a slot?
    show us header file.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    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: QTimer - Why this is not working?

    another thing is u are connecting the slot every time u click .. so first time it will call the slot test_func once and next click it will call it twice parallely and thrice ... keep on increasing the connect ..
    "Behind every great fortune lies a crime" - Balzac

Similar Threads

  1. Replies: 8
    Last Post: 27th March 2013, 11:51
  2. Extending QTimer()
    By rishid in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2009, 01:59
  3. QThread/QObject and QTimer
    By swiety in forum Qt Programming
    Replies: 2
    Last Post: 25th January 2008, 08:37
  4. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31
  5. Replies: 5
    Last Post: 6th March 2007, 05:34

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.