如何设置QTextEdit的框架形状

How to set the frame shape of a QTextEdit

本文关键字:框架 QTextEdit 何设置 设置      更新时间:2023-10-16

我只是无法从语法上理解类概念中的枚举。我正在尝试禁用QTextEdit的帧:

//in a header for my custom class where the main element is the textField
QTextEdit* textField;
...
//displaying it myCustomClass.cpp
textField = new QTextEdit(this);
textField->Shape = QFrame::NoFrame;

我得到错误"无效使用枚举::Qframe::Shape"。正确的语法是什么?为什么?

这是无效的C++:QTextEdit没有这样的"Shape"成员。此外,Qt使用适当的封装,因此形状是而不是成员变量暴露的

你必须调用一个设置框架形状的方法,令人惊讶的是,它被称为setFrameShape

textField->setFrameShape(QFrame::NoFrame);