Question

I have a couple of group boxes in my application that are placed on same parent widget and each of them is provided with a child instance of QwtPlot. User can operate with plots via mouse (zooming, panning...).

I want to keep a track in which group box is user currently working (which is the focus group box). However events are handled in standard way, so if user works with plot, mouse events are consumed by this plot. I want to know that user is working with a specific groupbox no matter what operations he performs with its nested widgets.

Any suggestions?

Was it helpful?

Solution

Ok I have found a solution. QGroupBox has to be reimplemented, for example:

class CustomGroupBox : public QGroupBox {
  Q_OBJECT
public:
  CustomGroupBox(QWidget *parent = 0) : QGroupBox(parent);
  CustomGroupBox(const QString &title, QWidget* parent = 0) : QGroupBox(title, parent);
signals:
  void customReleased();
protected:
  void mouseReleaseEvent(QMouseEvent* event) {
    emit customReleased();
    QGroupBox::mouseReleaseEvent(event);
  }
};

Then I can connect customReleased() of all my group boxes to one slot which will handle sender() object and keep track about active group box.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top