Skip to content

Commit

Permalink
Dodata je postavka za temu 4 (qt)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robotmurlock committed Oct 27, 2021
1 parent eff6714 commit 126d9a3
Show file tree
Hide file tree
Showing 20 changed files with 465 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tema04_qt/01_qt_instalacija/README.md
Original file line number Diff line number Diff line change
@@ -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)
18 changes: 18 additions & 0 deletions tema04_qt/02_qt_cppreference/README.md
Original file line number Diff line number Diff line change
@@ -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.
Binary file added tema04_qt/02_qt_cppreference/cppreference.pdf
Binary file not shown.
73 changes: 73 additions & 0 deletions tema04_qt/03_nonqt_aplikacija/.gitignore
Original file line number Diff line number Diff line change
@@ -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

6 changes: 6 additions & 0 deletions tema04_qt/03_nonqt_aplikacija/03_nonqt_aplikacija.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TEMPLATE = app
CONFIG += console c++17
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp
17 changes: 17 additions & 0 deletions tema04_qt/03_nonqt_aplikacija/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>
#include <vector>

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<int> 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;
}
34 changes: 34 additions & 0 deletions tema04_qt/04_qt_aplikacija/04_qt_aplikacija.pro
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tema04_qt/04_qt_aplikacija/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
![illustration](illustration.png)
Binary file added tema04_qt/04_qt_aplikacija/illustration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions tema04_qt/04_qt_aplikacija/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();

return a.exec();
}
44 changes: 44 additions & 0 deletions tema04_qt/04_qt_aplikacija/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QPushButton>

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;
}
30 changes: 30 additions & 0 deletions tema04_qt/04_qt_aplikacija/mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

// 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
72 changes: 72 additions & 0 deletions tema04_qt/04_qt_aplikacija/mainwindow.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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>147</width>
<height>139</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pbtnIncrement">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Increment</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lScore">
<property name="text">
<string>Score: 0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>147</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuGame_inc">
<property name="title">
<string>game inc.</string>
</property>
</widget>
<addaction name="menuGame_inc"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
24 changes: 24 additions & 0 deletions tema04_qt/05_qmake/.qmake.stash
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions tema04_qt/05_qmake/hello.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "hello.hpp"
#include <iostream>

inline void hello()
{
std::cout << "Hello World!" << std::endl;
}

void nhello(int n)
{
for(unsigned i=0; i<n; i++)
hello();
}
8 changes: 8 additions & 0 deletions tema04_qt/05_qmake/hello.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef __HELLO__
#define __HELLO__

inline void hello();

void nhello(int n);

#endif
Loading

0 comments on commit 126d9a3

Please sign in to comment.