在主窗口中看不到我的标签和布局
Can't see my label and layout in MainWindow
delete layout();
QGridLayout *gridLayout = new QGridLayout(this);
int cont = 0;
for (Category c : categories) {
cont++;
QVBoxLayout *verticalLayout;
verticalLayout = new QVBoxLayout();
gridLayout->setSpacing(cont);
gridLayout->addLayout(verticalLayout, 0, cont - 1);
QLabel *l;
l = new QLabel();
l->setText(c.getName());
l->setAlignment(Qt::AlignCenter);
verticalLayout->addWidget(l);
}
在mainWindow
中,当在categories
for
循环时,我想添加一个带有标签的gridLayout
和verticalLayout
您没有为任何小部件设置布局。您必须调用函数setLayout(gridLayout)您想要应用它的小部件。希望能有所帮助
相关文章:
- 如何使用C/C++在MacOSX中获得键盘布局
- Vulkan验证层不断在VkQueuePresentKHR()上抛出图像布局错误
- 布局兼容类型的并集
- Qt自定义QPush按钮未显示在布局上
- C 和 C++ 中开关语句的案例标签的常量值,但显示不同的行为
- 如何正确指定 goto 语句的标签?
- 按钮悬停在 QT 中垂直布局的选项卡小部件中不起作用
- 使用g++静态初始化带有命名标签的嵌套C++结构
- 调整布局上的 QGraphicsView 小部件的大小
- 通过水平滚动条更改标签
- 如何在qt中将对象添加到现有布局中?--已解决
- 将布局映射到内存地址
- C++继承的虚拟类的内存布局
- 从 QFontDatabase 设置 QFont 将所有标签设置为等宽字体?Qt C++
- 在C++中存储要输入的标签列表
- 如何在等效列表中查找最小的连接标签
- 检查nullptr是否100%保护内存布局不受segfault影响
- C++ Python 的扩展 - 安全内存访问和内存布局
- 在主窗口中看不到我的标签和布局
- 在网格布局中调整标签的大小