Reputation:
I have a problem with the size of widget in Qt. I am Using it to display some game pictures, but it doesn't fit in there, it just adds two scrollbars, which is not what I need.
I tried this:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->maze = new MazeGUI();
QHBoxLayout * layout = new QHBoxLayout;
layout->addWidget(this->maze);
ui->widget->setLayout(layout);
ui->widget->resize(800, 600);
}
It works when I use "ui->widget->resize(200, 200);" which is smaller than some default size. But when I try some bigger number like in example, it doesn't work, just sets the QWidget size to the default size.
Edit: Maybe this will help solving the problem.
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>50</x>
<y>10</y>
<width>511</width>
<height>361</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
Upvotes: 2
Views: 7298