我无法从语法上理解类概念中的枚举。 我试图禁用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”。什么是正确的语法和原因?
答案 0 :(得分:2)
这是无效的C ++:QTextEdit没有这样的“Shape”成员。此外, Qt使用适当的封装,因此形状不由成员变量公开。
你必须调用一个设置框架形状的方法,并且令人惊讶地,它被称为setFrameShape
!
textField->setFrameShape(QFrame::NoFrame);