문제

다음 코드 줄을 구축 할 때 이상한 오류가 발생합니다. (나는 QVector와 qthread를 들고있다).

nodeProcess.h :

class NodeProcess : public QThread
{       public:
        NodeProcess();

        unsigned int create_NewProcess(int priority);
        NodeProcess operator[](int relativeID); private:
        int priority;
        unsigned int ID;
        unsigned int threadCount;

        QVector<NodeProcess> mProcess; 

};
.

nodeProcess.cpp :

NodeProcess::NodeProcess()
{
    threadCount = 0;
}

unsigned int NodeProcess::create_NewProcess(int priority){
    this->priority = priority;

    threadCount++;
    NodeProcess newProcess;
    mProcess.append(newProcess);
    return threadCount;
}

NodeProcess NodeProcess::operator[](int relativeID)
{
    return mProcess[relativeID];
}
.

누군가 내가 뭘 잘못하고 있는지 아이디어? 어떤 힌트가 나를 도울 것입니다 :).

In file included from ..\..\..\..\5.2.1\mingw48_32\include/QtCore/qalgorithms.h:45:0,
                 from ..\..\..\..\5.2.1\mingw48_32\include\QtCore/qvector.h:45,
                 from ..\..\..\..\5.2.1\mingw48_32\include\QtCore/QVector:1,
                 from ..\NodeProcessModelling\nodeprocess.h:4,
                 from ..\NodeProcessModelling\nodeprocess.cpp:1:
..\..\..\..\5.2.1\mingw48_32\include/QtCore/qobject.h: In copy constructor 'QThread::QThread(const QThread&)':
..\..\..\..\5.2.1\mingw48_32\include/QtCore/qobject.h:465:20: error: 'QObject::QObject(const QObject&)' is private
     Q_DISABLE_COPY(QObject)
                    ^
..\..\..\..\5.2.1\mingw48_32\include/QtCore/qglobal.h:978:5: note: in definition of macro 'Q_DISABLE_COPY'
     Class(const Class &) Q_DECL_EQ_DELETE;\
     ^
In file included from ..\..\..\..\5.2.1\mingw48_32\include\QtCore/QThread:1:0,
                 from ..\NodeProcessModelling\nodeprocess.h:5,
                 from ..\NodeProcessModelling\nodeprocess.cpp:1:
..\..\..\..\5.2.1\mingw48_32\include\QtCore/qthread.h:57:21: error: within this context
 class Q_CORE_EXPORT QThread : public QObject
                     ^
In file included from ..\NodeProcessModelling\nodeprocess.cpp:1:0:
..\NodeProcessModelling\nodeprocess.h: In copy constructor 'NodeProcess::NodeProcess(const NodeProcess&)':
..\NodeProcessModelling\nodeprocess.h:7:7: note: synthesized method 'QThread::QThread(const QThread&)' first required here 
 class NodeProcess : public QThread
       ^
..\NodeProcessModelling\nodeprocess.cpp: In member function 'NodeProcess NodeProcess::operator[](int)':
..\NodeProcessModelling\nodeprocess.cpp:19:31: note: synthesized method 'NodeProcess::NodeProcess(const NodeProcess&)' first required here 
     return mProcess[relativeID];
                               ^
In file included from ..\..\..\..\5.2.1\mingw48_32\include/QtCore/qalgorithms.h:45:0,
                 from ..\..\..\..\5.2.1\mingw48_32\include\QtCore/qvector.h:45,
                 from ..\..\..\..\5.2.1\mingw48_32\include\QtCore/QVector:1,
                 from ..\NodeProcessModelling\nodeprocess.h:4,
                 from ..\NodeProcessModelling\nodeprocess.cpp:1:
..\..\..\..\5.2.1\mingw48_32\include\QtCore/qthread.h: In instantiation of 'void QVector<T>::append(const T&) [with T = NodeProcess]':
..\NodeProcessModelling\nodeprocess.cpp:13:31:   required from here
..\..\..\..\5.2.1\mingw48_32\include/QtCore/qglobal.h:979:12: error: 'QObject& QObject::operator=(const QObject&)' is private
     Class &operator=(const Class &) Q_DECL_EQ_DELETE;
            ^
..\..\..\..\5.2.1\mingw48_32\include/QtCore/qobject.h:465:5: note: in expansion of macro 'Q_DISABLE_COPY'
     Q_DISABLE_COPY(QObject)
     ^
In file included from ..\..\..\..\5.2.1\mingw48_32\include\QtCore/QThread:1:0,
                 from ..\NodeProcessModelling\nodeprocess.h:5,
                 from ..\NodeProcessModelling\nodeprocess.cpp:1:
..\..\..\..\5.2.1\mingw48_32\include\QtCore/qthread.h:57:21: error: within this context
 class Q_CORE_EXPORT QThread : public QObject
                     ^
In file included from ..\NodeProcessModelling\nodeprocess.cpp:1:0:
..\NodeProcessModelling\nodeprocess.h:7:7: note: synthesized method 'QThread& QThread::operator=(const QThread&)' first required here 
 class NodeProcess : public QThread
       ^
In file included from ..\..\..\..\5.2.1\mingw48_32\include\QtCore/QVector:1:0,
                 from ..\NodeProcessModelling\nodeprocess.h:4,
                 from ..\NodeProcessModelling\nodeprocess.cpp:1:
..\..\..\..\5.2.1\mingw48_32\include\QtCore/qvector.h:569:19: note: synthesized method 'NodeProcess& NodeProcess::operator=(const NodeProcess&)' first required here 
         *d->end() = copy;
                   ^
Makefile.Debug:227: recipe for target 'debug/nodeprocess.o' failed
mingw32-make[1]: *** [debug/nodeprocess.o] Error 1
mingw32-make[1]: Leaving directory 'C:/Qt/Tools/QtCreator/bin/build-NodeProcessModelling-Desktop_Qt_5_2_1_MinGW_32bit-Debug'
makefile:34: recipe for target 'debug' failed
mingw32-make: *** [debug] Error 2
18:03:35: The process "C:\Qt\Tools\mingw48_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project NodeProcessModelling (kit: Desktop Qt 5.2.1 MinGW 32bit)
When executing step 'Make'
.

도움이 되었습니까?

해결책

누군가 내가 뭘 잘못하고 있는지 아이디어?

꽤 몇 가지!

첫째, Qthread를 사용하려는 경우 실제로 QThread가 스레딩을 관리하는 방법을 변경하지 않는 한 실제로 계획하지 않는 한 상속하지 마십시오. qthread는 실제 스레드 자체보다 스레드 컨트롤러가 더 많습니다.

해야 할 일은 클래스를 만들고 Qobject에서 파생 한 다음 그런 다음 새 qthread로 이동하는 것입니다. "는 정말로 qthreads "여기에서 예제 코드를 템플릿으로 사용하십시오.

또한 NodeProcess 인스턴스의 QVector를 생성합니다. 이렇게하면 복사 생성자가 호출되지만 Object는 Qobject에서 파생됩니다. Copy 생성자가 비공개입니다. 그래서이 오류가 발생합니다 : -

오류 : 'qobject :: qobject (const qobject &)'는 비공개

노드 프로세스 포인터의 QVector를 사용해야합니다. QVector 를 사용하여 필요에 따라 할당하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top