Home › Forum › SOFA › Programming with SOFA › [SOLVED] How to use QTableWidget class in a sofa component plugin
Tagged: 64_bits, Qt, scene file, SOFA, SOFA_1706, Windows_10
- This topic has 11 replies, 3 voices, and was last updated 5 years, 10 months ago by rubab123.
-
AuthorPosts
-
10 January 2019 at 12:00 #12753rubab123Blocked
Hello there.
I need to make a graph when the animation is done in modeler. For this I have written a plugin component which gives me total run time occupied by my scene file. Now I need to display that time information in a graph. For this I use sqlite 3 to save data in database and then QTable widget to display data from there. But how can I use QtableWidget in sofa, as it is not getting included in my component, when i include as #include <Qtablewidget> it says cannot add file, what can i do.
Is there any way to resolve it.
Any guidance from your busy schedule would highly be appreciated.
Many Thanks.10 January 2019 at 19:19 #12759HugoKeymasterHey @rubab,
I am no expert, but I noticed other devs about your issue. They should come back to you soon.
Hugo
10 January 2019 at 21:25 #12760BineshBlockedDear @rubab,
For including qt class, you must find Qt library in your plugin cmakeFor Example ::
find_package(Qt5 COMPONENTS Core REQUIRED) if(Qt5Core_FOUND) message("Simedix: Using Qt5") set(QT5_NO_LINK_QTMAIN 1) find_package(Qt5 COMPONENTS Gui OpenGL Network Core Multimedia REQUIRED) set(EXT_QT_INCLUDES ${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS}) #target_include_directories(${EXT_QT_INCLUDES}) set(EXT_QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5OpenGL_LIBRARIES}) qt5_wrap_cpp(MOC_FILES ${MOC_HEADER_FILES}) set(MOC_FILES_GROUP "Generated") qt5_wrap_ui(FORM_FILES ${UI_FILES}) set(FORM_FILES_GROUP "Generated") endif() target_link_libraries(${PROJECT_NAME} ${EXT_QT_LIBRARIES})
Best wishes,
Behnam Binesh
11 January 2019 at 08:15 #12761rubab123BlockedThank you alot @Hugo and @Binesh!
I have added this in my plugin cmake file. But still I am not able to include Qtablewidget.h in my component.11 January 2019 at 11:29 #12766rubab123Blocked@Behnam @Binesh I got this error when I added code in cImg plugin
CMake Error at applications/plugins/CImgPlugin/CMakeLists.txt:47 (target_link_libraries):
Cannot specify link libraries for target “CImgPlugin” which is not built by
this project.11 January 2019 at 11:41 #1276811 January 2019 at 11:45 #12769rubab123Blocked@Binesh Thnaks alot for your concern
Here is cmake file for my EvaluationMetrixx plugin:cmake_minimum_required(VERSION 2.8.12) project(EvaluationMetrixx) set(HEADER_FILES initMyPlugin.h InjectorPositioningMetrics.h InjectorHandlingMetrics.h ObjectHandlingMetrics.h SphereHandlingMetrics.h ICSISimulationMetrics.h ) set(SOURCE_FILES initMyPlugin.cpp InjectorPositioningMetrics.cpp InjectorHandlingMetrics.cpp ObjectHandlingMetrics.cpp SphereHandlingMetrics.cpp ICSISimulationMetrics.cpp ) find_package(Qt5 COMPONENTS Core REQUIRED) if(Qt5Core_FOUND) message("Simedix: Using Qt5") set(QT5_NO_LINK_QTMAIN 1) find_package(Qt5 COMPONENTS Gui OpenGL Network Core Multimedia REQUIRED) set(EXT_QT_INCLUDES ${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS}) #target_include_directories(${EXT_QT_INCLUDES}) set(EXT_QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5OpenGL_LIBRARIES}) qt5_wrap_cpp(MOC_FILES ${MOC_HEADER_FILES}) set(MOC_FILES_GROUP "Generated") qt5_wrap_ui(FORM_FILES ${UI_FILES}) set(FORM_FILES_GROUP "Generated") endif() target_link_libraries(${PROJECT_NAME} ${EXT_QT_LIBRARIES}) find_package(SofaFramework REQUIRED) add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} SofaCore SofaMisc SofaMiscCollision SofaMiscEngine SofaMiscFem SofaMiscForceField SofaMiscMapping SofaMiscSolver SofaMiscTopology SofaGuiCommon ) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-DSOFA_BUILD_EVALUATIONMETRIXX") install(TARGETS EvaluationMetrixx RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
11 January 2019 at 11:56 #12771rubab123Blocked@Benish I just resolved this error. Now camke is built successfully, I have added this
target_link_libraries(${PROJECT_NAME} SofaCore SofaMisc SofaMiscCollision SofaMiscEngine SofaMiscFem SofaMiscForceField SofaMiscMapping SofaMiscSolver SofaMiscTopology SofaGuiCommon EXT_QT_LIBRARIES )
Still in my plugin component when I add QtableWidget.h It says, cannot be included. Moreover, when I build my plugin in Visual studio, at the end it gives me this:
Error LNK1181 cannot open input file ‘EXT_QT_LIBRARIES.lib’ EvaluationMetrixx C:\sofa\build\applications\plugins\EvaluationMetrixx\LINK 1
Any idea?
@Benish11 January 2019 at 12:22 #12772BineshBlockedDear @rubab,
I think your cmake list is incorrect,
Please use this codes in your cmake filetarget_link_libraries(${PROJECT_NAME} SofaCore SofaMisc SofaMiscCollision SofaMiscEngine SofaMiscFem SofaMiscForceField SofaMiscMapping SofaMiscSolver SofaMiscTopology SofaGuiCommon) target_link_libraries(${PROJECT_NAME} ${EXT_QT_LIBRARIES})
Best,
Behnam Binesh
11 January 2019 at 12:34 #12773rubab123BlockedThanks alooot!!!
it realy worked @Binesh…11 January 2019 at 14:03 #1277423 January 2019 at 07:45 #12865rubab123BlockedHello @Behnam Binesh;
I have a new issue now, I am basically working in sofa and compiling it in Visual studio. I have some values saved in sqlite database. Then I have created a qt application using Qt creator and saved that data from sqlite to QTableView, which gives me a table containing sqlite data.
Now i want to use that table in sofa (my plugin component) so that it displays table, for this some one told me to put your header ,source and ui files (from Qt application) into the cmake of plugins, which I did same. I built cmake and opened project in VS, now that qt files are inaccessible like ui->setup (ui not found) errors like tableview not defined etc, I hope you understand my problem.
Here I share my cmake with you:cmake_minimum_required(VERSION 2.8.12)
project(EvaluationMetrixx)set(HEADER_FILES
initMyPlugin.h
InjectorPositioningMetrics.h
InjectorHandlingMetrics.h
ObjectHandlingMetrics.h
SphereHandlingMetrics.h
ICSISimulationMetrics.h
mainwindow.h)
set(SOURCE_FILES
initMyPlugin.cpp
InjectorPositioningMetrics.cpp
InjectorHandlingMetrics.cpp
ObjectHandlingMetrics.cpp
SphereHandlingMetrics.cpp
ICSISimulationMetrics.cpp
mainwindow.cpp)
set(UI_FILES
mainwindow.ui
)set(MOC_FILES
moc_mainwindow.cpp
)
find_package(Qt5 COMPONENTS Core REQUIRED)
if(Qt5Core_FOUND)
message(“Simedix: Using Qt5”)
set(QT5_NO_LINK_QTMAIN 1)find_package(Qt5 COMPONENTS Gui OpenGL Network Core Multimedia REQUIRED)
set(EXT_QT_INCLUDES ${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS})
#target_include_directories(${EXT_QT_INCLUDES})set(EXT_QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5OpenGL_LIBRARIES})
qt5_wrap_cpp(MOC_FILES ${MOC_HEADER_FILES})
set(MOC_FILES_GROUP “Generated”)
qt5_wrap_ui(FORM_FILES ${UI_FILES})
set(FORM_FILES_GROUP “Generated”)
endif()find_package(SofaFramework REQUIRED)
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${UI_FILES})
target_link_libraries(${PROJECT_NAME} SofaCore SofaMisc SofaMiscCollision SofaMiscEngine SofaMiscFem SofaMiscForceField SofaMiscMapping SofaMiscSolver SofaMiscTopology SofaGuiCommon)
target_link_libraries(${PROJECT_NAME} ${EXT_QT_LIBRARIES})set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS “-DSOFA_BUILD_EVALUATIONMETRIXX”)
install(TARGETS EvaluationMetrixx
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib) -
AuthorPosts
- You must be logged in to reply to this topic.