franco.amato
21st January 2010, 16:41
Hi,
I have a doubt regarding focus. Maybe this is not a Qt related topic, if so sorry in advance.
I have a Widget inherited from QWidget having some children ( push buttons and other widgets ).
So:
class WaveWidget : public QWidget
{
Q_OBJECT
public:
WaveWidget( QWidget* parent = 0 );
virtual ~WaveWidget();
void setSoundFile( QString soundName_ );
void closeSoundFile( QString soundName_ );
public slots:
void playSound();
void stopSound();
void zoomIn();
void zoomOut();
void setZoomFactor( float f );
signals:
void zoomFactorChanged( float );
protected:
virtual void focusInEvent( QFocusEvent * );
virtual void focusOutEvent( QFocusEvent * );
virtual void keyPressEvent( QKeyEvent* event );
private:
WaveDisplay* m_WaveDisplay;
PanelInfo* m_panel;
SoundData* m_wave;
QPushButton* button1;
QPushButton* button2;
QPushButton* button3;
QPushButton* button4;
QPushButton* button5;
QPushButton* button6;
QPushButton* button7;
QPushButton* button8;
QPushButton* button9;
QPushButton* button10;
QPushButton* m_zoomInBtn;
QPushButton* m_zoomOutBtn;
QLabel* m_titleLabel;
QLed* m_statusLed;
float m_ZoomFactor;
};
The WaveWidget should react to keyboard keys pressed ( I reimplemented keyPressEvent ).
If initially WaveWidget has focus, pressing tab the focus pass to it's children. In this case WaveWidges still react to keyboard keypressed?
I would like yes, but I don't know how to implement such behaviour.
Best Regards
I have a doubt regarding focus. Maybe this is not a Qt related topic, if so sorry in advance.
I have a Widget inherited from QWidget having some children ( push buttons and other widgets ).
So:
class WaveWidget : public QWidget
{
Q_OBJECT
public:
WaveWidget( QWidget* parent = 0 );
virtual ~WaveWidget();
void setSoundFile( QString soundName_ );
void closeSoundFile( QString soundName_ );
public slots:
void playSound();
void stopSound();
void zoomIn();
void zoomOut();
void setZoomFactor( float f );
signals:
void zoomFactorChanged( float );
protected:
virtual void focusInEvent( QFocusEvent * );
virtual void focusOutEvent( QFocusEvent * );
virtual void keyPressEvent( QKeyEvent* event );
private:
WaveDisplay* m_WaveDisplay;
PanelInfo* m_panel;
SoundData* m_wave;
QPushButton* button1;
QPushButton* button2;
QPushButton* button3;
QPushButton* button4;
QPushButton* button5;
QPushButton* button6;
QPushButton* button7;
QPushButton* button8;
QPushButton* button9;
QPushButton* button10;
QPushButton* m_zoomInBtn;
QPushButton* m_zoomOutBtn;
QLabel* m_titleLabel;
QLed* m_statusLed;
float m_ZoomFactor;
};
The WaveWidget should react to keyboard keys pressed ( I reimplemented keyPressEvent ).
If initially WaveWidget has focus, pressing tab the focus pass to it's children. In this case WaveWidges still react to keyboard keypressed?
I would like yes, but I don't know how to implement such behaviour.
Best Regards