如何设置QTextEdit的框架形状

时间:2013-07-13 13:20:27

标签: c++ qt enums

我无法从语法上理解类概念中的枚举。 我试图禁用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;

我收到错误“无效使用enum :: Qframe :: Shape”。什么是正确的语法和原因?

1 个答案:

答案 0 :(得分:2)

这是无效的C ++:QTextEdit没有这样的“Shape”成员。此外, Qt使用适当的封装,因此形状由成员变量公开。

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

textField->setFrameShape(QFrame::NoFrame);