Results 1 to 3 of 3

Thread: Trouble Connecting QTimeLine to QPushButton Slot that was developed using the Creator

  1. #1
    Join Date
    Dec 2016
    Posts
    7
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Trouble Connecting QTimeLine to QPushButton Slot that was developed using the Creator

    Hello Everyone!

    Im having an issue that is most likely easy to solve but I'm not getting it. I have created a QPushButton in Creator and have developed functions that run perfectly fine using the release() slot. It works flawlessly! My problem now is I want to connect a QTimeLine to the already created release slot. My overall goal is that I have PixMaP Array of acquired images and i want to play them back in My QGraphicsView at variable speeds...basically creating an animation of captured frames...

    I am almost finished and can send any single frame at a time to my GraphicsView, change them and so on...but now i would like to animate them by showing all 600 frames in the graphics view one at a time every 150 ms creating a 4 sec animation that is displayed almost in real time since my camera grabs 150 frame per second. Originally i thought a for loop was needed but come to find out the QtimeLine creates the loop which is really cool! Just for ease of understanding..instead of changing frames im just going to get the currentFrame count to display to console..if i can understand and get something as simple as that to work i can take care of the rest.

    I am posting my code below..as of now my program tells me:

    "QMetaObject::connectSlotsByName: No matching signal for on_play_released(int)"
    "QObject::connect: No such slot QPushButton::released(int counting) in ..\mainwindow.cpp:57"
    "QObject::connect: (receiver name: 'play')"



    As if it does not exist and I'm using Q_Object in my header file as well...

    // Namespace for using cout.
    using namespace Pylon;
    using namespace std;
    using namespace Basler_UsbCameraParams;
    using namespace cv;
    using namespace std;



    QVector<QImage> ImageArr;
    QVector<QPixmap> PixMapArr;
    QTimeLine *timeLine = new QTimeLine(150);
    int counting = 0;


    MainWindow::MainWindow(QWidget *parent) :

    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    QGraphicsScene *Begin = new QGraphicsScene();
    QGraphicsTextItem *startScene = new QGraphicsTextItem;

    startScene->setPos(150,70);
    startScene->setScale(2);
    startScene->setPlainText("Please Ready Camera Position or Begin Acquisition");
    Begin->addItem(startScene);
    ui->graphicsView->setScene(Begin);


    timeLine->setFrameRange(0, 600);
    QObject::connect(timeLine, SIGNAL(frameChanged(int)), ui->play, SLOT(on_play_released(int counting)));
    QObject::connect(ui->play, SIGNAL(released()), timeLine, SLOT(start()));

    }


    void MainWindow:n_play_released(int counting)
    {

    cout << timeLine->currentFrame() << endl;
    }

    Thank you all who can lend any advice!!!

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Trouble Connecting QTimeLine to QPushButton Slot that was developed using the Cre

    QObject::connect(timeLine, SIGNAL(frameChanged(int)), ui->play, SLOT(on_play_released(int counting)));
    First, this is incorrect syntax for a connect() statement. I assume ui->play points to a QPushButton. QPushButton does not have a slot named "on_play_released()". Your MainWindow does, however. It should be (and please note the use of CODE tags when posting source code):

    Qt Code:
    1. connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(on_play_released(int)));
    To copy to clipboard, switch view to plain text mode 

    Also note that your MainWindow class is derived from QObject, so it is not necessary to qualify connect() with "QObject::" since MainWindow inherits the connect() method from QObject.

    As a matter of personal preference, I never create signal / slot connections using Qt Designer, because it "hides" these connections inside the UI file and the code that gets generated by MOC. I prefer to make explicit signal and slot definitions in C++ code, and to make the connections there too. Saves a lot of head-scratching when you can't figure out why a slot is getting executed when there is no obvious code that would do it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    MVivonetto (13th January 2017)

  4. #3
    Join Date
    Dec 2016
    Posts
    7
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Trouble Connecting QTimeLine to QPushButton Slot that was developed using the Cre

    Thanks d! Sorry I would have responded sooner but I think qtcentre was down for some reason because I could not access it. Anyway, I will definitely use code tags to next time.

Similar Threads

  1. Connecting custom signal and slot
    By DmitryNik in forum Newbie
    Replies: 4
    Last Post: 12th September 2011, 14:15
  2. Connecting signal and slot by name
    By grayfox in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2011, 09:00
  3. Trouble Connecting to Microsoft Access *.accdb files
    By FuNkDaDdY in forum Qt Programming
    Replies: 1
    Last Post: 10th November 2010, 10:18
  4. Connecting two classes with slgnal and slot
    By Benjamin in forum Newbie
    Replies: 2
    Last Post: 22nd January 2009, 13:16
  5. Connecting to a slot not within an Obejct
    By Matze-o in forum Qt Programming
    Replies: 2
    Last Post: 10th November 2008, 14:02

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.