I have a QWidget form
, then I have added QTextEdit
on the form, but there is a space(margin) in the top.
我有一个QWidget表单,然后我在表单上添加了QTextEdit,但顶部有一个空格(边距)。
I tried to use the following:
我试着使用以下内容:
QWidget *widget = new QWidget(this);
widget->layout()->setContentsMargins(0,0,0,0);
But unfortunately, it did not do what I want.
但不幸的是,它并没有做我想要的。
How to remove that space(margin) to be like the left
, right
and down
side ?
如何删除该空间(边距),如左,右和下?
Full code
完整代码
QWidget *widget = new QWidget(this);
QTextEdit *TextEdit = new QTextEdit(widget);
QMdiSubWindow *mdiWindows = ui->mdiArea->addSubWindow(widget);
mdiWindows->setGeometry(5, 5, 300, 250);
mdiWindows->setWindowTitle(finfo.baseName());
mdiWindows->setWindowState(Qt::WindowMaximized);
mdiWindows->layout()->addWidget(TextEdit);
mdiWindows->layout()->setContentsMargins(0,0,0,0);
TextEdit->setText(cache);
widget->setMaximumHeight(0);
mdiWindows->show();
2 个解决方案
#1
1
Try addding a
尝试添加一个
widget->layout()->setSpacing(0);
#2
0
Is it the menubar? Try removing it if you don't need it.
是菜单栏吗?如果您不需要,请尝试将其删除。
Also, try to position the QTextedit
properly on central widget by clicking the widget and using arrow keys to make its position exact.
此外,尝试通过单击窗口小部件并使用箭头键将QTextedit正确放置在*窗口小部件上。
Also, there might be a layout causing this problem. Please check it.
此外,可能存在导致此问题的布局。请检查一下。
#1
1
Try addding a
尝试添加一个
widget->layout()->setSpacing(0);
#2
0
Is it the menubar? Try removing it if you don't need it.
是菜单栏吗?如果您不需要,请尝试将其删除。
Also, try to position the QTextedit
properly on central widget by clicking the widget and using arrow keys to make its position exact.
此外,尝试通过单击窗口小部件并使用箭头键将QTextedit正确放置在*窗口小部件上。
Also, there might be a layout causing this problem. Please check it.
此外,可能存在导致此问题的布局。请检查一下。