Question: Hello stackoverflow users,

Today I am using the overflow:scroll; property so I can hide all content but allow users to see it with a scroll bar.

See below picture:
![enter image description here](https://i.stack.imgur.com/emp4W.png)

You can see that the scroll bars appear even when not needed. Is there a way I can hide the scroll bar until needed, ie when there is actually overflowing content. It is a cosmetic issue for me as the scroll bar at the moment are naturally locked since there is no overflowing content, so why display it (I would prefer it not to be displayed just in case others have different opinions).

Regards

Answer: 
You're calling `IconWigdet::paintEvent` directly. This is not allowed. Instead of calling it directly, call [`QWidget::update`](http://qt-project.org/doc/qt-5/qwidget.html#update) or [`QWidget::repaint`](http://qt-project.org/doc/qt-5/qwidget.html#repaint).

```
GroupWidget::GroupWidget()
{ 
    groupLayout->addWidget(icon, 0, 1, 1, 1, 0);
    this->setLayout(groupLayout);
    icon->show();
    // QPaintEvent *e;
    // icon->paintEvent(e); this is not allowed
    icon->update(); // do this instead
}

```

Though I don't see why would you call anything there. Just calling `Icon->show();` should be enough. Qt will automatically schedule a paint event.
Try this instead of your constructor

```
GroupWidget::GroupWidget()
{ 
    groupLayout->addWidget(icon, 0, 1, 1, 1, 0);
    this->setLayout(groupLayout);
    setMinimumSize(100,100); 
    setMaximumSize(200,200); 
    icon->show();
}

```

This will work,