
Originally Posted by
Lawand
The functions sa->horizontalScrollBar() and sa->verticalScrollBar() return pointers to the area's scrollbars.
You can then use the valueChanged() signal found in either these scrollbars...
It doesn't work. The scrollbar is not shown.
The code is this:
CentralWidget
::CentralWidget( QWidget* parent
/* = 0 */ ) m_pVbox( 0 ),
m_pWaveU( 0 ),
m_pWaveD( 0 )
{
/* vertical layout */
/* scroll area */
saU->setWidgetResizable( true );
saD->setWidgetResizable( true );
saU->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
saD->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
/* waveform */
m_pWaveU = new WaveDisplay( this );
m_pWaveD = new WaveDisplay( this );
saU->setWidget( m_pWaveU );
saD->setWidget( m_pWaveD );
m_pVbox->addWidget( saU );
QScrollBar *scrollBar
= saU
->horizontalScrollBar
();
connect(scrollBar, SIGNAL(sliderMoved(int)), this, SLOT(scrollMoved(int)));
m_pVbox->addSpacing( 15 );
m_pVbox->addWidget( saD );
setLayout(m_pVbox);
}
CentralWidget::CentralWidget( QWidget* parent /* = 0 */ )
: QWidget(parent),
m_pVbox( 0 ),
m_pWaveU( 0 ),
m_pWaveD( 0 )
{
/* vertical layout */
m_pVbox = new QVBoxLayout( this );
/* scroll area */
saU = new QScrollArea( this );
saD = new QScrollArea( this );
saU->setWidgetResizable( true );
saD->setWidgetResizable( true );
saU->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
saD->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
/* waveform */
m_pWaveU = new WaveDisplay( this );
m_pWaveD = new WaveDisplay( this );
saU->setWidget( m_pWaveU );
saD->setWidget( m_pWaveD );
m_pVbox->addWidget( saU );
QScrollBar *scrollBar = saU->horizontalScrollBar();
connect(scrollBar, SIGNAL(sliderMoved(int)), this, SLOT(scrollMoved(int)));
m_pVbox->addSpacing( 15 );
m_pVbox->addWidget( saD );
setLayout(m_pVbox);
}
To copy to clipboard, switch view to plain text mode
where CentralWidget is the central widget of a QMainWindow.
I don't know where I'm wrong. The scroll bar is not displayed.
Bookmarks