0

我只是无法在语法上掌握类概念中的枚举。我正在尝试禁用 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”。什么是正确的语法,为什么?

4

1 回答 1

2

That's invalid C++: there's no such "Shape" member for QTextEdit. Moreover, Qt uses proper encapsulation, so the shape is not exposed by a member variable.

You have to call a method which sets the frame shape, and surprisingly enough, it's called setFrameShape!

textField->setFrameShape(QFrame::NoFrame);
于 2013-07-13T13:24:10.087 回答