Results 1 to 5 of 5

Thread: Adequate treatment of signal from widget (float, float, float)

  1. #1
    Join Date
    May 2011
    Posts
    22
    Qt products
    Qt4

    Default Adequate treatment of signal from widget (float, float, float)

    Dear all,

    For my first program, I am using the amazing MathGL library to paint graphs and trajectories. The incorporated QMathGL class is extended from QWidget, and I have added this to my MainWindow.

    It sends a signal void mouseClick(float,float,float). I am now capturing this signal from the QMathGL ui->qmgl with QWidget ui->vehicles_tab using
    Qt Code:
    1. connect(ui->qmgl, SIGNAL(mouseClick(float, float, float)), ui->vehicles_tab, SLOT(on_graph_clicked(float, float, float)));
    To copy to clipboard, switch view to plain text mode 
    But within the class definition of ui->vehicles_tab i have defined slot on_graph_clicked as
    Qt Code:
    1. void VehiclesTab::on_graph_clicked(float x,float y,float z)
    To copy to clipboard, switch view to plain text mode 
    in order to handle the value of the floats (x, y and z).

    This seems to work, but i still get the warning:
    QMetaObject::connectSlotsByName: No matching signal for on_graph_clicked(float,float,float)

    What am I doing wrong?

    Thank you in advance!

  2. #2
    Join Date
    Apr 2011
    Posts
    124
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: Adequate treatment of signal from widget (float, float, float)

    Actually, if you're getting that message it's not working -- the connect() isn't happening. ALWAYS test (eq, with an assert) the result of a connect to make sure it succeeds.

    Are you sure your slot is declared as a slot?

  3. #3
    Join Date
    May 2011
    Posts
    22
    Qt products
    Qt4

    Thumbs up Re: Adequate treatment of signal from widget (float, float, float)

    Commenting the connect statement prevents the click event from occurring. Enabling it again, restores the desired behavior. So it seems to work properly, but comes with the mentioned warning. In the meantime, i'll try to seek out what an assert is, en how to use it.

    Commenting the connect statement prevents the click event from occurring. Enabling it again, restores the desired behavior. So it seems to work properly, but comes with the mentioned warning. In the meantime, i'll try to seek out what an assert is, en how to use it.


    Added after 49 minutes:


    Ah got it: I named my slot on_graph_clicked(), but on_ is reserved for slots with special meaning. Nice to know though.
    Last edited by nomiz; 18th May 2011 at 15:14.

  4. #4
    Join Date
    Apr 2011
    Posts
    124
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: Adequate treatment of signal from widget (float, float, float)

    Yeah, that's something I'd probably read about and forgotten. Though I wouldn't expect the message unless you're doing a QMetaObject::connectSlotsByName call somewhere.

    Assert, for connect is like this:
    Qt Code:
    1. bool success = connect(...);
    2. Q_UNUSED(success); // Prevents an "unused warning" if compiled in production mode
    3. Q_ASSERT(success); // Will throw an assertion error if "success" is false. Compiles away in production mode.
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Adequate treatment of signal from widget (float, float, float)

    connectSlotsByName() is called at the end of setupUi() so if one is using ui classes, the routine gets called.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. float display
    By freekill in forum Newbie
    Replies: 2
    Last Post: 13th May 2009, 12:43
  2. Replies: 1
    Last Post: 10th February 2009, 09:42
  3. float a = textedit???
    By Colx007 in forum Qt Programming
    Replies: 3
    Last Post: 10th October 2007, 17:25
  4. How Do I Float a QToolBar?
    By dvmorris in forum Qt Programming
    Replies: 7
    Last Post: 29th April 2007, 19:01
  5. float
    By mickey in forum General Programming
    Replies: 5
    Last Post: 25th July 2006, 11:52

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.