Howto Install and Configure qtcreator on Ubuntu

Source: Internet
Author: User

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, refer to:http://qt-project.org/quarterly/view/using_cmake_to_build_q T_projects.

Herewe give a complete CMake project using QT, the complete program canbe download destiny/5262651


Qtcmaketest

│├──bin

│├──build

│├──cmakelists.txt

│├──include

││├──qtcmaketest.h

││└──qtvtktest.h~

│├──qrc

│├──src

││├──main.cpp

││└──qtcmaketest.cpp

│└──ui

│└──qtcmaketest.ui



Inthis project we don't 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 is 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> 


======================================================================


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_object public
:
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");
}


======================================================================

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.