PDA

View Full Version : QT ---> C++ How to make?



VerexPL
2nd November 2014, 15:34
I made in QT creator a Gui and i want to make it a C++ working gui.
I build it and Qt has created a new folder with .exe (Gui, dont working, because it saying that i dont get DLL) and moc_mainwindow.cpp
I tried to put the code from moc_mainwindow.cpp into Code::Blocks but i didnt work. http://screenshu.com/static/uploads/temporary/zh/gr/hp/eswokt.jpg

Gui.pro


#-------------------------------------------------
#
# Project created by QtCreator 2014-11-01T20:13:02
#
#-------------------------------------------------
QT += webkit
QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = GUI
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui


Mainwindow.h


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private slots:
void on_Gospodarze_clicked();

void on_Zatrzymaj_clicked();

void on_Goscie_clicked();


private:
Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H


Main.cpp

#include "mainwindow.h"
#include <QApplication>

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

return a.exec();
}


Mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"
int GospodarzeL = 2;
int ZatrzymajL = 2;
int GoscieL = 2;

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::on_Gospodarze_clicked()
{
if (GospodarzeL < 1) {
ui->GospodarzeL->setText("<font color='Red'>OFF</font>");
GospodarzeL = 2;
} else {
ui->GospodarzeL->setText("<font color='Green'>ON</font>");
GospodarzeL = 0;}
}


void MainWindow::on_Zatrzymaj_clicked()
{
if (ZatrzymajL < 1) {
ui->ZatrzymajL->setText("<font color='Red'>OFF</font>");
ZatrzymajL = 2;
} else {
ui->ZatrzymajL->setText("<font color='Green'>ON</font>");
ZatrzymajL = 0;}
}

void MainWindow::on_Goscie_clicked()
{
if (GoscieL < 1) {
ui->GoscieL->setText("<font color='Red'>OFF</font>");
GoscieL = 2;
} else {
ui->GoscieL->setText("<font color='Green'>ON</font>");
GoscieL = 0;}
}


When i was starting the gui from Qt creator it was working.

anda_skoa
2nd November 2014, 18:11
I made in QT creator a Gui and i want to make it a C++ working gui.
I build it and Qt has created a new folder with .exe (Gui, dont working, because it saying that i dont get DLL)

Did your installation routine maybe forget to copy the Qt DLLs to the program installation folder?

Cheers,
_

VerexPL
2nd November 2014, 18:15
Did your installation routine maybe forget to copy the Qt DLLs to the program installation folder?

Cheers,
_

I don't see, any DLL's in my instalator.
I downloaded: "qt-opensource-windows-x86-1.6.0-5-online"
But for my is important that i can made this gui in code::blocks working.
Because i would to make more functions

ChrisW67
2nd November 2014, 20:02
So your problem is that when you run your compiled program in Code::Blocks... Your IDE needs to ensure the enironment use to run the program allows the program to find all the libraries it is dependent on. In the case of a program needing Qt libraries this means the Qt libraries can be found in the PATH (asuming you are a Windows user).