PDA

View Full Version : problem painting



eric_vi
12th August 2009, 19:25
within an MDI I have subwindows as QScrollArea with a QWidget scrollAreaWidgetContents inside



childScrollArea::childScrollArea(QWidget *parent) :
QScrollArea(parent),
m_ui(new Ui::childScrollArea)
{

scrollAreaWidgetContents = new QWidget();
childScrollArea->setWidget(scrollAreaWidgetContents);

scrollAreaWidgetContents->show();

}


void childScrollArea::paintEvent(QPaintEvent * /* event */)
{
QPainter painter(this);

painter.fillRect(QRect(0, 0, 300, 300), Qt::blue );
}


unfortunately the paint event in this case does not do any painting in the window!

what do i do wrong?

Thanks for any hint

wysota
12th August 2009, 20:01
QScrollArea has a viewport, you should probably be painting on that, if at all.

eric_vi
13th August 2009, 00:26
ok the viewport did the display part, but i cannot get the scroll bar to show, whatever the size of my widget inside... so what else is missing?

wysota
13th August 2009, 08:32
It depends what the widget does. Does it have a layout?

eric_vi
13th August 2009, 16:52
i tried with a layout around the widget.. i don't get it to work..

also what is strange is that i do not have any event like mouse event within the minimum size of my scroll area, outside the minimum size i do have mouse event. i am sure it is related and i am missing something, i have no clue what

wysota
13th August 2009, 23:07
If it doesn't have a layout then its size is probably not constrained in any way. How do you set the size of this widget?