Qt+VTK: build successful but run failed...
-
Hi Hostel,
First of all, Happy New Year for you.
-About creating the pointer type, I tried to write
MainWindow* mainWin= new MainWindow();but I got a build error:
undefined reference to MainWindow:MainWindow()-About the debug, I built with vtkdebug & then did debug with netbeans, I got the same signal error BUT with debug error:
no registersthis happens only in the lines:
mainWin->resize(256,256);
mainWin->show();so, when I commented these lines, it runs but of course I can't see anything (no application window).
-
Thanx, and Happy New Year for you too :)
If you have in code a pointer to MainWindow without constructiong by new a object, then when you call
@
mainWin->resize();
@
then you have a SIGSEGV.You have to make a object.
You should resolve a build error with 'undefined reference(...)'.
Try solve it by:
@
MainWindow::MainWindow() :
QMainWindow() // you forget about constructor of base class
{
-QVTKWidget widget;- // this not looks good - this should be a member in private section of class
widget = new QVTKWidget(); // change to this
// your code
}
@then run qmake and try build again.
-
Hello Hostel,
Thanks alot.
You seem an expert with coding.Let me tell you what I did changed, to see if I got you correctly:
in .cpp
@MainWindow::MainWindow() : QMainWindow()
{
widget = new QVTKWidget();
}@in main
@ MainWindow* mainWin = new MainWindow();@I did this, but still get undefined reference error.
-
here is the header file.
exactly, this is the error.@#ifndef SOFTWARE_H
#define SOFTWARE_H#include <QMainWindow>
#include <QVTKWidget.h>QT_BEGIN_NAMESPACE
class QAction;
class QMenu;
QT_END_NAMESPACEclass MainWindow : public QMainWindow
{
Q_OBJECTpublic:
MainWindow();protected:
void closeEvent(QCloseEvent *event);private slots:
void open();
bool exportAs();
void about();private:
QVTKWidget widget;void createActions(); void createMenus(); void createToolBars(); void createStatusBar(); void setCurrentPath(const QString &fileName); QString curPath; QMenu *fileMenu; QToolBar *fileToolBar; QAction *openAct; QAction *exportAsAct; QAction *exitAct; QAction *aboutAct;
};
#endif
@ -
here it is:
@HEADERS = SoftWare.h
SOURCES = TestSoftWare.cpp
SoftWare.cppRESOURCES = application.qrc
install
target.path = $$/home/adam-linux/Documents/TestSoftWare-Debug
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS application.pro images
sources.path = $$/home/adam-linux/Documents/TestSoftWare-Debug
INSTALLS += target sources@ -
I don't know why this is not working. Try re-run qmake and re-build all. If not help then try remove this lines from .pro file:
@
install
target.path = $$/home/adam-linux/Documents/TestSoftWare-Debug
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS application.pro images
sources.path = $$/home/adam-linux/Documents/TestSoftWare-Debug
INSTALLS += target sources
@
and re-run qmake and re-build all.I don't have any new ideas.