diff --git a/tema04_qt/01_qt_instalacija/README.md b/tema04_qt/01_qt_instalacija/README.md new file mode 100644 index 0000000..3209d92 --- /dev/null +++ b/tema04_qt/01_qt_instalacija/README.md @@ -0,0 +1,26 @@ +# Qt Instalacija + +## Linux +`sudo apt-get install build-essential`\ +`sudo apt-get install qtcreator`\ +`sudo apt-get install qt5-default` + +### Linux docs i API: +``sudo apt install `apt-cache search 5-examples | grep qt | grep example | awk '{print $1 }' | xargs` ``\ +``sudo apt install `apt-cache search 5-doc | grep "Qt 5 " | awk '{print $1}' | xargs` ``\ +`sudo apt-get install build-essential qtcreator qt5-default` + +### Ako nešto nedostaje: +``sudo apt install `apt-cache search qt | grep 5- | grep ^qt | awk '{print $1}' | xargs` `` + +### izvor: +[qt linux installation guide](https://doc.qt.io/qt-5/linux.html)`\ +[stackoverflow linux installation guide](https://stackoverflow.com/questions/48147356/install-qt-on-ubuntu) + + --- +## Mac: +[qt macos installation guide](https://doc.qt.io/qt-5/macos.html) + + --- +## Windows: +[qt windows installation guide](https://doc.qt.io/qt-5/windows.html) diff --git a/tema04_qt/02_qt_cppreference/README.md b/tema04_qt/02_qt_cppreference/README.md new file mode 100644 index 0000000..03930ad --- /dev/null +++ b/tema04_qt/02_qt_cppreference/README.md @@ -0,0 +1,18 @@ +# Upustvo za dodavanje cppreference u Qt Creator + +## Skidanje cppreference knjige +1. Otvoriti zvaničnu cppreference stranicu: [cppreference](https://en.cppreference.com); +2. Kliknuti na `offline archive` pri dnu u okviru sekcije `News`; +3. Pronaći sekciju `Qt help book` i tu kliknuti na zipovan `qch book`; +4. Skinuti `qch book` (Napomena: Ako ne može da se skine preko Chrome pretraživača, skinuti preko drugog pretraživača). + +## Dodavanje cppreference u Qt Creator (pogledati cppreference.pdf datoteku) +1. Otvoriti Qt creator; +2. Kliknuti na `Tools` u opcijama na vrhu, pa na `Options...`; +3. Kliknuti na `Help` sa leve strana; +4. Pri vrhu kliknuti na `Documentation`; +5. Kliknuti na `Add...` i dodati `*.qch` fajl. + +## Korišćenje cppreference u okviru Qt Creator-a +Sada se u okviru Qt moze koristiti cppreference tako sto se klikne na `Help` +sa leve strane i u opcijama izabrati cppreference. diff --git a/tema04_qt/02_qt_cppreference/cppreference.pdf b/tema04_qt/02_qt_cppreference/cppreference.pdf new file mode 100644 index 0000000..c543ff6 Binary files /dev/null and b/tema04_qt/02_qt_cppreference/cppreference.pdf differ diff --git a/tema04_qt/03_nonqt_aplikacija/.gitignore b/tema04_qt/03_nonqt_aplikacija/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/tema04_qt/03_nonqt_aplikacija/.gitignore @@ -0,0 +1,73 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/tema04_qt/03_nonqt_aplikacija/03_nonqt_aplikacija.pro b/tema04_qt/03_nonqt_aplikacija/03_nonqt_aplikacija.pro new file mode 100644 index 0000000..254bc42 --- /dev/null +++ b/tema04_qt/03_nonqt_aplikacija/03_nonqt_aplikacija.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +CONFIG += console c++17 +CONFIG -= app_bundle +CONFIG -= qt + +SOURCES += main.cpp diff --git a/tema04_qt/03_nonqt_aplikacija/main.cpp b/tema04_qt/03_nonqt_aplikacija/main.cpp new file mode 100644 index 0000000..3e09935 --- /dev/null +++ b/tema04_qt/03_nonqt_aplikacija/main.cpp @@ -0,0 +1,17 @@ +#include +#include + +int main() +{ + // Ako se postavi kursor misa preko npr. 'std::vector' i postoji offline cppreference + // onda se sa desne strane u okviru qtcreator-a otvara dokumentacija + // Napomena: Vrlo moguce da ovo nece raditi bez std namespace-a + std::vector vec{1, 2, 3, 4, 5}; + std::cout << "Hello World!" << std::endl; + + for(auto val: vec) + std::cout << val << " "; + std::cout << std::endl; + + return 0; +} diff --git a/tema04_qt/04_qt_aplikacija/04_qt_aplikacija.pro b/tema04_qt/04_qt_aplikacija/04_qt_aplikacija.pro new file mode 100644 index 0000000..8402b04 --- /dev/null +++ b/tema04_qt/04_qt_aplikacija/04_qt_aplikacija.pro @@ -0,0 +1,34 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2020-10-08T18:01:16 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = 04_qt_aplikacija +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui diff --git a/tema04_qt/04_qt_aplikacija/README.md b/tema04_qt/04_qt_aplikacija/README.md new file mode 100644 index 0000000..754c383 --- /dev/null +++ b/tema04_qt/04_qt_aplikacija/README.md @@ -0,0 +1 @@ +![illustration](illustration.png) diff --git a/tema04_qt/04_qt_aplikacija/illustration.png b/tema04_qt/04_qt_aplikacija/illustration.png new file mode 100644 index 0000000..18d2f4e Binary files /dev/null and b/tema04_qt/04_qt_aplikacija/illustration.png differ diff --git a/tema04_qt/04_qt_aplikacija/main.cpp b/tema04_qt/04_qt_aplikacija/main.cpp new file mode 100644 index 0000000..b48f94e --- /dev/null +++ b/tema04_qt/04_qt_aplikacija/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/tema04_qt/04_qt_aplikacija/mainwindow.cpp b/tema04_qt/04_qt_aplikacija/mainwindow.cpp new file mode 100644 index 0000000..b914550 --- /dev/null +++ b/tema04_qt/04_qt_aplikacija/mainwindow.cpp @@ -0,0 +1,44 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow), + m_score(0) +{ + ui->setupUi(this); + + // Objekat koji emituje signal: pbtnIncrement + // Signal koji se emituje: QPushButton::clicked + // Objekat koji prima signal: this (MainWindow) + // Slot (fja): MainWindow::inc + + // Napomena: slot i signal su f-je koje imati isti potpis tj. iste argument + // Specijalan slucaj: signal ima vise argumenata od slota, onda se visak ignorise + + // Rezultat: + // Klikom na dugme 'Increment' se poziva f-ja inc() i samim tim se uvecava + // trenutni rezultat igre za 1 + connect( + ui->pbtnIncrement, + &QPushButton::clicked, + this, + &MainWindow::inc + ); +} + +void MainWindow::inc() +{ + m_score++; + // QString::number je staticka metoda koja prevodi broj u nisku + // tj. vraca QString + QString updatedScoreText = "score: " + QString::number(m_score); + ui->lScore->setText(updatedScoreText); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/tema04_qt/04_qt_aplikacija/mainwindow.h b/tema04_qt/04_qt_aplikacija/mainwindow.h new file mode 100644 index 0000000..0cee544 --- /dev/null +++ b/tema04_qt/04_qt_aplikacija/mainwindow.h @@ -0,0 +1,30 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +// namespace - prostor imena - uopstenje pakate iz Jave +// namespace Ui grupise MainWindow i generisan Ui_MainWindow + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + // explicit konstruktor onemogucava implicitno pozivanje konstruktora + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +public Q_SLOTS: + void inc(); + +private: + Ui::MainWindow *ui; + int m_score; +}; + +#endif // MAINWINDOW_H diff --git a/tema04_qt/04_qt_aplikacija/mainwindow.ui b/tema04_qt/04_qt_aplikacija/mainwindow.ui new file mode 100644 index 0000000..29090e2 --- /dev/null +++ b/tema04_qt/04_qt_aplikacija/mainwindow.ui @@ -0,0 +1,72 @@ + + + MainWindow + + + + 0 + 0 + 147 + 139 + + + + MainWindow + + + + + + + + 100 + 16777215 + + + + Increment + + + + + + + Score: 0 + + + Qt::AlignCenter + + + + + + + + + 0 + 0 + 147 + 22 + + + + + game inc. + + + + + + + TopToolBarArea + + + false + + + + + + + + diff --git a/tema04_qt/05_qmake/.qmake.stash b/tema04_qt/05_qmake/.qmake.stash new file mode 100644 index 0000000..e1d04e4 --- /dev/null +++ b/tema04_qt/05_qmake/.qmake.stash @@ -0,0 +1,24 @@ +QMAKE_CXX.INCDIRS = \ + /usr/include/c++/7 \ + /usr/include/x86_64-linux-gnu/c++/7 \ + /usr/include/c++/7/backward \ + /usr/lib/gcc/x86_64-linux-gnu/7/include \ + /usr/local/include \ + /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed \ + /usr/include/x86_64-linux-gnu \ + /usr/include +QMAKE_CXX.LIBDIRS = \ + /usr/lib/gcc/x86_64-linux-gnu/7 \ + /usr/lib/x86_64-linux-gnu \ + /usr/lib \ + /lib/x86_64-linux-gnu \ + /lib +QMAKE_CXX.QT_COMPILER_STDCXX = 201402L +QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7 +QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 5 +QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 +QMAKE_CXX.COMPILER_MACROS = \ + QT_COMPILER_STDCXX \ + QMAKE_GCC_MAJOR_VERSION \ + QMAKE_GCC_MINOR_VERSION \ + QMAKE_GCC_PATCH_VERSION diff --git a/tema04_qt/05_qmake/hello.cpp b/tema04_qt/05_qmake/hello.cpp new file mode 100644 index 0000000..776f73e --- /dev/null +++ b/tema04_qt/05_qmake/hello.cpp @@ -0,0 +1,13 @@ +#include "hello.hpp" +#include + +inline void hello() +{ + std::cout << "Hello World!" << std::endl; +} + +void nhello(int n) +{ + for(unsigned i=0; i + +// U okviru qtcreator-a postoji debager + +int main() +{ + int n; + std::cin >> n; + n++; + nhello(n); + n--; + + return 0; +} diff --git a/tema04_qt/05_qmake/makefile_vladimir.pdf b/tema04_qt/05_qmake/makefile_vladimir.pdf new file mode 100644 index 0000000..3f3be31 Binary files /dev/null and b/tema04_qt/05_qmake/makefile_vladimir.pdf differ diff --git a/tema04_qt/06_debug/TODO.txt b/tema04_qt/06_debug/TODO.txt new file mode 100644 index 0000000..e69de29