Question: ![application](https://i.stack.imgur.com/29oze.jpg)

I want to build a Qt5.2 Application in C++ with Visual Studio 2013. I apply the `QWidget::resize` function to set the size of the QWidget object in the image above to 1200\*800. But it seems that the QWidget object can't be that large(there are vertical and horizontal scroll bars).

How can I get the size of the QWidget object expanded to 1200\*800 and remove the scroll bars? And how can I get the object at the centre of the application both vertically and horizontally?

Answer: 
You need to provide a minimal example of what's going on. We shouldn't have to guess.

All I can see is up to three widgets: the top level one, the `QScrollArea`, and whatever widget is inside of the scroll area. If that's the case, then the scroll area is not managed by a layout, and when you resize the top level widget, the scroll area's size remains unchanged.

I see two solutions, assuming that `MyContentsWidget` is the widget that draws your genetics thingamajingy (if that's what it is).

1. Get rid of the toplevel widget and use the `QScrollArea` as a toplevel widget:

```
int main(int argc, char ** argv) {
  QApplication app(argc, argv);
  QScrollArea area;
  MyContentsWidget contents;
  area.setWidget(&contents);
  area.show();
  return app.exec();
}

```
2. Add a layout to the toplevel widget, so that it'll resize the scroll area appropriately:

```
class MyWindow : public QWidget {
  QGridLayout m_layout;
  QScrollArea m_area;
  MyContentsWidget m_contents;
public:
  MyWindow(QWidget * parent = 0) : QWidget(parent), m_layout(this) {
    m_layout.addWidget(&m_area, 0, 0);
    m_area.setWidget(&m_contents);
  }
};

```

In both cases, the order of declaration is the opposite of the order of destruction, and it is important since you must ensure that `MyContentsWidget` is destructed before the scroll area.
Add your widget to QLayout:

```
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(widget);
mainWindow->setLayout(layout);

```