- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
假设我有这样的东西
void someClass::start()
{
QLabel* sb = new QLabel();
sb->setText("Hello World");
ui.verticalLayout->addWidget(sb);
}
addWidget 是否使 sb 成为 someClass 的子级,以便在我删除 someClass 时 sb 也被删除?如果这是真的,我怎么知道通常哪些方法将父对象分配给对象?
最佳答案
来自 http://qt-project.org/doc/qt-4.8/layout.html :
When you use a layout, you do not need to pass a parent when constructing the child widgets. The layout will automatically reparent the widgets (using QWidget::setParent()) so that they are children of the widget on which the layout is installed.
关于c++ - 内存管理 - addwidget 是否分配父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20853816/
我想对 CodeMirror 进行一些扩展。 addWidget 方法似乎是一个很有前途的起点。该文件指出 addWidget(pos, node, scrollIntoView) Puts node
假设我有这样的东西 void someClass::start() { QLabel* sb = new QLabel(); sb->setText("Hello World");
我在我的代码中使用了 QGridLayout,并且想将我的自定义小部件添加到 gridlayout,它无法与 addWidget(CustomWidget*) 一起使用。 这是在带有 Visual S
在将子 QWidget 添加到父 QWidget 后,我无法立即设置它的尺寸。问题是它根本没有设置几何图形: from PyQt4 import QtCore, QtGui class MyWid
我正在使用 QtRuby 开发一个 GUI 项目。但是,一旦我在我的 MainWindow 对象中添加了使用 GridLayout 的代码,我就开始收到此错误: mainwindow.rb:37:in
我在 QVBoxlayout 的 addWidget(widget,stretch,alignment) 方法中遇到 Alignment-Parameter 问题。 我正在将 QTableview 添
我正在尝试使用 addWidget 函数将FigureCanvasQTAgg 参数作为小部件添加到某些布局中,但发生了 TypeError。仅当尝试运行使用 pyinstaller 构建的独立应用程序
我正在尝试将 QWidget 指针参数 (plot2) 传递给 Qt 的 addWidget(QWidget * T,. ..) 将指向 QWidget 的指针作为其第一个参数的函数。如果我传递原始指
我是一名优秀的程序员,十分优秀!