compiling qt apps

9

Click here to load reader

Upload: jussi-pohjolainen

Post on 09-May-2015

1.049 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Compiling Qt Apps

Compiling  Qt  -­‐  apps  

Jussi  Pohjolainen  Tampere  University  of  Applied  Sciences  

Page 2: Compiling Qt Apps

source.cpp  #include <QtWidgets>

int main(int argc, char *argv[]){ QApplication a(argc, argv);

QLabel b; b.setText("moi"); b.show();

return a.exec();}

Page 3: Compiling Qt Apps

Crea@ng  Project  

•  Create  new  projecBolder  and  save  the  source.cpp  into  the  folder  – /QtHelloWorld/source.cpp

•  Create  plaBorm  independent  project  file  – qmake –project

•  Creates  – /QtHelloWorld/QtHelloWorld.pro

Page 4: Compiling Qt Apps

pro?  ###################################################################### # Automatically generated by qmake (3.0) ke maaliskuuta 4 10:34:14 2015

######################################################################

TEMPLATE = app

TARGET = QtHelloWorld

INCLUDEPATH += .

# add this!

QT += widgets

# Input

SOURCES += source.cpp

Page 5: Compiling Qt Apps

qmake  

•  AGer  building  the  project  –  file,  we  well  create  a  pla$orm  specific  makefile  

•  makefile  =  informa@on  how  to  build  the  target  program  (compile  instruc@ons)  

•  In  Mac  OS  X,  the  qmake  creates  automa@cally  Xcode  –  project  files.  Use:  qmake -spec macx-g++

•  In  other  systems,  qmake should  be  enough.  

Page 6: Compiling Qt Apps

qmake  usage  on  Mac  OS  X  

Page 7: Compiling Qt Apps

make  and  running  

•  make  will  compile  the  applica@on  using  the  instruc@ons  in  the  makefile  

•  AGer  compila@on  you  can  run  the  applica@on  

Page 8: Compiling Qt Apps

Compiling  and  Running  

Page 9: Compiling Qt Apps

Build  Steps  

•  qmake –project – Creates  plaBorm  independent  project  file  

•  qmake – Creates  plaBorm  specific  makefile  

•  make – Compiles  the  applica@on  

•  ./helloworld – Starts  the  app  (depends  on  the  plaBorm)