2016-12-16 2 views
-3

GUI :잘못된 사용

class PythonShell: public QMainWindow 
{ 
    Q_OBJECT 

public: 
    PythonShell(QWidget *parent = 0); 
    ~PythonShell(); 
    QPlainTextEdit* OutputTextEdit; 

MAIN.CPP :

static PyObject* redir_print(PyObject* self, PyObject* args) 
{ 
    const char* s; 
    if(!PyArg_ParseTuple(args,"s",&s)) 
     return nullptr; 
    PythonShell::OutputTextEdit->appendPlainText(s); 
    Py_RETURN_NONE; 
} 

Error: Invalid use of non-static data member OutputTextEdit .

문제점은 무엇입니까?

+5

오류가 명백해 회원에 액세스 할 수 있습니다. ** 당신은'PythonShell' 인스턴스에서'OutputTextEdit'을 호출해야합니다 **, ** 정적으로 사용하지 ** 않습니다 ('PythonShell :: OutputTextEdit'는 불법입니다). – Mike

답변

0

PythonShell 개체를 생성하면 PythonShell을 실제 생활로 가져와야합니다.

PythonShell obj; 

한 다음

obj.OutputTextEdit->appendPlainText(s);