Qt Audiorecorder example - Connection of button

82 views Asked by At

Lastly I've studied the Audiorecorder example of QtCreator (http://qt-project.org/doc/qt-5/qtmultimedia-audiorecorder-example.html). There is a record-button that starts the recording after clicking it. But I could not find code like

connect(ui->recordButton, SIGNAL(clicked()), this, SLOT(toggleRecord())); 

or something similar. I don't understand why the recorder knows that I clicked the button. So I also can't adapt this button to my needs. Are there any other ways to connect a button to a function invisible, or did I just overlook it? I've heard something about meta objects moc-files, is this somehow related? If yes, how could I remove or change that and implement "normal" connections?

1

There are 1 answers

0
Bowdzone On BEST ANSWER

The connection can also be created in a *.ui-file. If you inspect the audiorecorder.ui you'll find the following code:

<connection>
    <sender>recordButton</sender>
    <signal>clicked()</signal>
    <receiver>AudioRecorder</receiver>
    <slot>toggleRecord()</slot>
    <hints>
        <hint>...</hint>
    </hints>
</connection>

which you can either adapt or remove completly and create the connect() statement you wrote in the AudioRecorder constructor.