Results 1 to 3 of 3

Thread: Signal from variable

  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Signal from variable

    I'm trying to set up a signal/slot for a change in variable value.
    The variable is global, ::gOper
    In the class it is declared in, is the following code:

    Qt Code:
    1. connect(gOper, SIGNAL(valueChanged()), this, SLOT(updateStats()));
    To copy to clipboard, switch view to plain text mode 

    But, it doesn't compile.
    error: no matching function for call to `MainWindow::connect(QString&, const char*, MainWindow* const, const char*)'

    So how do you refer to the variable? Or what am I doing wrong?

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Signal from variable

    The variable must be a QObject-derived class, not a QString.

    So create a class, give it a setter, getter and signal, and then use connect()

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

    waynew (18th November 2009)

  4. #3
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Signal from variable

    Tnx Fatjuicymole, I got it now.

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  3. nmake error during .pro compiling
    By mattia in forum Installation and Deployment
    Replies: 5
    Last Post: 18th June 2008, 10:15
  4. Possible signal mapper problem
    By MarkoSan in forum Qt Programming
    Replies: 13
    Last Post: 25th January 2008, 13:11

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.