Howto Install and Configure QtCreator on Ubuntu
来源:互联网 发布:fyzf后缀是什么软件 编辑:程序博客网 时间:2024/05/14 04:33
Howto Install and Configure QtCreator on Ubuntu
Install Qt from Ubuntu Software Center,just search qt and select qtcreator, select add-ons
after selecting add-ons, apply thechanges and then install v2.4.1.
Touse Qt in your CMake project, For more info please refer to:http://qt-project.org/quarterly/view/using_cmake_to_build_qt_projects.
Herewe give a complete CMake project using Qt, the complete program canbe download at: http://download.csdn.net/detail/owldestiny/5262651
QtCMakeTest
│ ├── bin
│ ├── build
│ ├── CMakeLists.txt
│ ├── include
│ │ ├── QtCMakeTest.h
│ │ └── QtVtkTest.h~
│ ├── qrc
│ ├── src
│ │ ├── main.cpp
│ │ └── QtCMakeTest.cpp
│ └── ui
│ └── QtCMakeTest.ui
Inthis project we do not use qrc.
TheCMakeLists.txt is:
======================================================================
cmake_minimum_required(VERSION2.8)
project(QtCMakeTest)
#set(CMAKE_BUILD_TYPEdebug)
########################################################
#Qt
find_package(Qt4REQUIRED)
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
########################################################
########################################################
#Projectsettings
#set(PROJECT_SOURCESmain.cpp)#all sources files
set(LIBRARY_OUTPUT_PATH${PROJECT_SOURCE_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH${PROJECT_SOURCE_DIR}/bin)
include_directories(${PROJECT_SOURCE_DIR}/include${CMAKE_CURRENT_BINARY_DIR})#to include the moc ui generated ui_*.hs
aux_source_directory(${PROJECT_SOURCE_DIR}/src/PROJECT_SOURCES)
########################################################
########################################################
#GenerateQt files
set(PROJECT_HEADERS${PROJECT_SOURCE_DIR}/include/QtCMakeTest.h)#only headers includeQ_OBJECT
QT4_WRAP_CPP(PROJECT_HEADERS_MOC${PROJECT_HEADERS})
set(PROJECT_UI${PROJECT_SOURCE_DIR}/ui/QtCMakeTest.ui)#ui file
QT4_WRAP_UI(PROJECT_UI_UIC${PROJECT_UI})
#set(PROJECT_RC${PROJECT_SOURCE_DIR}/qrc)#resource files
#QT4_WRAP_RESOURCES(PROJECT_RC_RCC${PROJECT_RC})
########################################################
########################################################
#generateexecutables and link libraries
add_executable(QtCMakeTest${PROJECT_SOURCES} ${PROJECT_HEADERS_MOC} ${PROJECT_UI_UIC})#${PROJECT_RC_RCC})
target_link_libraries(QtCMakeTest${QT_LIBRARIES})
======================================================================
The QtCMakeTest.ui(only including one push button) can be generated and edited by QtDesigner as:
======================================================================
<?xml version="1.0"encoding="UTF-8"?><ui version="4.0"><class>mainWindow</class><widget class="QMainWindow"name="mainWindow"><property name="geometry"><rect><x>0</x><y>0</y><width>722</width><height>512</height></rect></property><property name="windowTitle"><string>Qt CMake Test</string></property><widget class="QWidget"name="centralwidget"><widget class="QPushButton"name="pushButtonTest"><property name="geometry"><rect><x>430</x><y>80</y><width>98</width><height>51</height></rect></property><property name="text"><string>PushButton</string></property></widget></widget><widget class="QStatusBar"name="statusbar"/></widget><resources/><connections/></ui>
======================================================================
The main.cpp is:
======================================================================
#include <QApplication>#include "QtCMakeTest.h"int main(int argc, char**argv){QApplication app(argc,argv);Qt_QtCMakeTest qtTest;qtTest.show();return app.exec();}
======================================================================
TheQtVtkTest.h is:
======================================================================
#include <QtGui/QMainWindow>#include "ui_QtCMakeTest.h"class Qt_QtCMakeTest: publicQMainWindow{Q_OBJECTpublic:Qt_QtCMakeTest();public:Ui::mainWindow ui;public slots:void OnButtonClicked();};
======================================================================
The QtCMakeTest.cpp is:
======================================================================
#include "QtCMakeTest.h"Qt_QtCMakeTest::Qt_QtCMakeTest(){ui.setupUi(this);connect(this->ui.pushButtonTest, SIGNAL(clicked()), this,SLOT(OnButtonClicked()));}voidQt_QtCMakeTest::OnButtonClicked(){this->ui.statusbar->showMessage("button clicked");}
======================================================================
- Howto Install and Configure QtCreator on Ubuntu
- Howto Install and Configure Doxygen for QtCreator on Ubuntu
- Howto Install and Configure VTK on Ubuntu
- Howto Install and Configure PCL on Ubuntu
- Howto Install and Configure ROS on Ubuntu
- Howto Install and Configure Chinese Input Methods on Ubuntu
- Howto install matlab on Ubuntu
- Install And Configure Nagios on Ubuntu 14.04 LTS
- How to Configure and Install ownCloud on Ubuntu 16.04
- How To Install and Configure Elasticsearch on Ubuntu 14.04
- install and configure git on Windows,Ubuntu,Mac
- ubuntu QT install and configure
- Howto install redmine on Ubuntu 16.04
- MinGW - 安装和配置 / MinGW - Howto Install And Configure
- MinGW - 安装和配置 / MinGW - Howto Install And Configure
- How to install and configure Apache, PHP, MySql and phpMyadmin on ubuntu
- Install and configure Jboss 7 on Linux
- [MySQL]Install and Configure MySQL in Ubuntu
- Java反射之内部类
- 学科前沿技术(了解开源化)
- 第六堂课后作业
- 第7周,项目3,友元类
- js中DOM动态创建相册并替换删除
- Howto Install and Configure QtCreator on Ubuntu
- java泛型
- 【大话设计模式系列】之观察者模式
- JavaEE参考示例 SpringSide 4.0 GA版杀青
- netfilter机制
- [Python]判断系统编码和字符编码chardet
- 第六堂课后作业
- 第四章(笔记总结)
- java instanceof的使用