I'm adapting the Qwt "realtime" example into a new application, and I would like to know when a user clicks on a plot in the main window. I will have multiple plots, and it's important to know which plot is clicked on. So far I have:

Qt Code:
  1. // Add plots and connect their signals
  2. // The "clicked()" signal is not actually doing anything
  3. void MainWindow::add_plots()
  4. {
  5. for (int i=0; i<m_num_rows; i++) {
  6. for (int j=0; j<m_num_cols; j++) {
  7. int index = i*m_num_cols+j;
  8. m_plots[index] = new QRealtimePlot(m_plots_frame);
  9. m_plots_layout->addWidget(m_plots[index], i, j);
  10. m_plots[index]->setMargin(4);
  11. connect(d_clearAction, SIGNAL(triggered()), m_plots[index], SLOT(clear()));
  12. connect(m_plots[index], SIGNAL(running(bool)), this, SLOT(showRunning(bool)));
  13. connect(m_plots[index], SIGNAL(clicked()), m_signal_mapper, SLOT(map()));
  14.  
  15. m_signal_mapper->setMapping(m_plots[index], index);
  16. }
  17. }
  18. connect(m_signal_mapper, SIGNAL(mapped(int)), this, SLOT(slot_plot_clicked(int)));
  19. }
To copy to clipboard, switch view to plain text mode 

QRealtimePlot is basically IncrementalPlot from the "realtime" example, including the Zoomer / ScrollZoomer classes. m_plot_layout is a QGridLayout whose parent is a frame in the MainWindow. d_clearAction is the "Clear" button on the toolbar, also straight out of the example.

So, here are my questions:

1) Is there a better way of doing this?
2) If not, what signal (if any) can I connect to m_signal_mapper to make this work?
3) I discovered that the clicked signal wasn't working by connecting to a slot that added an item to a list. This is an awful way of debugging. How do I do debugging output? Printing to stdout/stderr is not working (because of the QMainWindow class?)

Edit: I'm using Qt 4.7 and Qwt 6.0.0-rc5, and I'm very new to both.

Thanks,
Tom