Results 1 to 4 of 4

Thread: Signals and Slots

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Signals and Slots

    Hi

    I created a variable int c,whose value is to be updated through a slider, taking the value of the slider. The variable c will be then converted to a Qstring and output as the text of a QPushButton. I used the following code in the main.cpp. However, it does not work, since the button always displays the initial value of the slider, which suggests that the variable c is not being updated.



    QSlider *slider = new QSlider(Qt::Horizontal);
    slider->setRange(0, 130);

    QObject::connect(slider, SIGNAL(valueChanged(int)),
    slider, SLOT(setValue(int)));

    int Contador = slider->value();
    QPushButton *butao = new QPushButton;
    butao->setText(QString::number(Contador));


    Any suggestions why this is not working?

    Cheers
    Last edited by Maluko_Da_Tola; 28th July 2010 at 00:32.

Similar Threads

  1. Signals & Slots!
    By qtoptus in forum Qt Programming
    Replies: 2
    Last Post: 15th April 2010, 01:50
  2. Signals and Slots
    By 83.manish in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 10:31
  3. Signals and slots
    By sylvarant in forum Newbie
    Replies: 4
    Last Post: 11th September 2007, 15:48
  4. Signals and Slots
    By merry in forum Qt Programming
    Replies: 4
    Last Post: 22nd February 2007, 08:11
  5. Signals and Slots in dll
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2006, 08:12

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.