Commits

Vertexwahn  committed 4e611f5

Added a Qt5 demo.

  • Participants
  • Parent commits 3a47974

Comments (0)

Files changed (4)

File Qt5HelloWorld/CMakeLists.txt

 # Instruct CMake to run moc automatically when needed.
 set(CMAKE_AUTOMOC ON)
 
+cmake_policy(SET CMP0020 NEW)
+
 # Find the QtWidgets library
 find_package( Qt5Core REQUIRED )
 

File Qt5HelloWorld/main.cpp

-/*
-#include <qapplication.h>
-#include <qpushbutton.h>
-
-int main( int argc, char **argv )
-{
-    QApplication a( argc, argv );
-
-    QPushButton hello( "Hello world!", 0 );
-    hello.resize( 100, 30 );
-
-    //a.setMainWidget( &hello );
-    hello.show();
-    return a.exec();
-}
-*/
-
 #include <QtGui>
 #include <QtCore>
 #include <QLabel>

File Qt5HelloXmlSchema/CMakeLists.txt

+cmake_minimum_required(VERSION 2.8.10)
+
+project(Qt5HelloXmlSchema)
+
+# Find includes in corresponding build directories
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+# Instruct CMake to run moc automatically when needed.
+set(CMAKE_AUTOMOC ON)
+
+cmake_policy(SET CMP0020 NEW)
+
+# Find the QtWidgets library
+find_package( Qt5Core 			REQUIRED )
+find_package( Qt5Xml 			REQUIRED)
+find_package( Qt5XmlPatterns 	REQUIRED)
+
+# Tell CMake to create the Qt5HelloXmlSchema executable
+add_executable(Qt5HelloXmlSchema main.cpp)
+
+target_link_libraries( Qt5HelloXmlSchema
+    Qt5::WinMain  # <-- New target available via find_package ( Qt5Core )
+)
+
+# QtCopyBinaries
+add_custom_target(Qt5CopyBinaries
+	# todo: check if debug and release folder exist
+	# debug version
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/libEGLd.dll            ${CMAKE_BINARY_DIR}/Debug
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/libGLESv2d.dll         ${CMAKE_BINARY_DIR}/Debug
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Cored.dll 			${CMAKE_BINARY_DIR}/Debug
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Guid.dll 			${CMAKE_BINARY_DIR}/Debug
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Declaratived.dll 	${CMAKE_BINARY_DIR}/Debug
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Networkd.dll 		${CMAKE_BINARY_DIR}/Debug
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5OpenGLd.dll 		${CMAKE_BINARY_DIR}/Debug
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Scriptd.dll 		${CMAKE_BINARY_DIR}/Debug
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Sqld.dll 			${CMAKE_BINARY_DIR}/Debug
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Widgetsd.dll 		${CMAKE_BINARY_DIR}/Debug
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Xmld.dll 			${CMAKE_BINARY_DIR}/Debug
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5XmlPatternsd.dll 	${CMAKE_BINARY_DIR}/Debug
+	# release version
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/libEGL.dll 			${CMAKE_BINARY_DIR}/Release
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/libGLESv2.dll			${CMAKE_BINARY_DIR}/Release
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Core.dll 			${CMAKE_BINARY_DIR}/Release
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Gui.dll 			${CMAKE_BINARY_DIR}/Release
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Declarative.dll 	${CMAKE_BINARY_DIR}/Release
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Network.dll 		${CMAKE_BINARY_DIR}/Release
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5OpenGL.dll 			${CMAKE_BINARY_DIR}/Release
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Script.dll 			${CMAKE_BINARY_DIR}/Release
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Sql.dll 			${CMAKE_BINARY_DIR}/Release
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Widgets.dll 		${CMAKE_BINARY_DIR}/Release
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5Xml.dll 			${CMAKE_BINARY_DIR}/Release
+	COMMAND	${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt5XmlPatterns.dll 	${CMAKE_BINARY_DIR}/Release
+	
+	# Output Message
+	COMMENT "Copying Ot binaries from '${Qt5Core_DIR}/../../bin/' to '${CMAKE_BINARY_DIR}'" VERBATIM
+)
+
+# Use the Widgets module from Qt 5.
+qt5_use_modules(Qt5HelloXmlSchema Widgets Xml XmlPatterns)

File Qt5HelloXmlSchema/main.cpp

+#include <QtGui>
+#include <QtCore>
+#include <QLabel>
+#include <QMainWindow>
+#include <QApplication>
+#include <QPushButton>
+#include <QtXml>
+#include <QtXmlPatterns>
+
+int main(int argc,char *argv[])
+{
+	QApplication a(argc,argv);
+
+	QXmlSchema schema;
+
+ 	QPushButton hello( "Hello world!", 0 );
+
+	QMainWindow x; 
+	QString ss="Hello World!";
+	QLabel *ee=new QLabel(ss,0);
+	x.setCentralWidget(ee); 
+	x.show();
+	return a.exec();
+}