franco.amato
7th January 2010, 02:33
Hi, I'm becoming crazy with my customwidget.
I would write a widget that can grow orizontally and not vertically. ( fixed height and expanding width ) and I would attach a QScrollArea to it.
Well it don't work nothing.
My app inherits from QMainWidget and I do all in the centralwidget. ( in the central widget I would have 2 custom widget that's are WaveForm visualizer.
To test I add only one and it doesn't work.
Here the code:
CentralWidget::CentralWidget( QWidget* parent /* = 0 */ )
: QWidget(parent),
m_pVbox( 0 ),
m_pWaveU( 0 )
{
/* vertical layout */
m_pVbox = new QVBoxLayout( this );
/* scroll area */
saU = new QScrollArea( this );
saU->setWidgetResizable( true );
saU->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
/* waveform */
m_pWaveU = new WaveDisplay( saU );
m_pWaveU->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_pWaveU->setMinimumSize( QSize(1000, 200) );
saU->setWidget( m_pWaveU );
m_pVbox->addWidget( saU );
QScrollBar *scrollBar = saU->horizontalScrollBar();
scrollBar->setSliderDown( true );
m_pVbox->addWidget( saU );
setLayout(m_pVbox);
}
I have lots of problems with this code:
If I set
QSizePolicy::Fixed for the vertical size the widget is not shown
The scroll bar is only displayed when I resize the widget at the minimum size
If I draw outsize the visible part of the widget I can not see what I displayed. The scrollbar doesn't allow me to see the graph
And other, if I call resize( w, h ) inside the widget, it's not resized. The width() routine give to me always the same value.
i'm really confused. Is 1 month that I try to do this work without any success.
I'll be very happy to get some help from this mailing list.
Best Regards,
Franco
I would write a widget that can grow orizontally and not vertically. ( fixed height and expanding width ) and I would attach a QScrollArea to it.
Well it don't work nothing.
My app inherits from QMainWidget and I do all in the centralwidget. ( in the central widget I would have 2 custom widget that's are WaveForm visualizer.
To test I add only one and it doesn't work.
Here the code:
CentralWidget::CentralWidget( QWidget* parent /* = 0 */ )
: QWidget(parent),
m_pVbox( 0 ),
m_pWaveU( 0 )
{
/* vertical layout */
m_pVbox = new QVBoxLayout( this );
/* scroll area */
saU = new QScrollArea( this );
saU->setWidgetResizable( true );
saU->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
/* waveform */
m_pWaveU = new WaveDisplay( saU );
m_pWaveU->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_pWaveU->setMinimumSize( QSize(1000, 200) );
saU->setWidget( m_pWaveU );
m_pVbox->addWidget( saU );
QScrollBar *scrollBar = saU->horizontalScrollBar();
scrollBar->setSliderDown( true );
m_pVbox->addWidget( saU );
setLayout(m_pVbox);
}
I have lots of problems with this code:
If I set
QSizePolicy::Fixed for the vertical size the widget is not shown
The scroll bar is only displayed when I resize the widget at the minimum size
If I draw outsize the visible part of the widget I can not see what I displayed. The scrollbar doesn't allow me to see the graph
And other, if I call resize( w, h ) inside the widget, it's not resized. The width() routine give to me always the same value.
i'm really confused. Is 1 month that I try to do this work without any success.
I'll be very happy to get some help from this mailing list.
Best Regards,
Franco