PDA

View Full Version : No rule to make target



Emit
31st October 2014, 08:41
I tried to run a program but the process stops due to the error


:-1: error: No rule to make target '../../../../../IBO_win03_1/mainwindow.ui', needed by 'ui_mainwindow.h'. Stop.

.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_pshOdpriDatoteko_clicked();

void on_pshShraniDatoteko_clicked();

void on_actionIzhod_triggered();

void on_actionOdpri_triggered();

void on_actionShrani_kot_triggered();

private:
Ui::MainWindow *ui;

QString dat;
};

#endif // MAINWINDOW_H

main

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

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

return a.exec();
}

.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QDebug>
#include <QFile>
#include <QTextStream>
#include <QMessageBox>


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

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

void MainWindow::on_pshOdpriDatoteko_clicked()
{
dat = QFileDialog::getOpenFileName(
this,
"Odpri datoteko",
"C://",
"Vse datoteke (*.*)");

/*
QMessageBox::information(
this,
"",
dat);
*/

QFile datoteka(dat);
if (!datoteka.open(QIODevice::ReadOnly))
QMessageBox::information(
this,
"",
datoteka.errorString()
);
QTextStream in(&datoteka);
ui->tb->setText(in.readAll());
datoteka.close();
}

void MainWindow::on_pshShraniDatoteko_clicked()
{
QFile datoteka(dat);
if (!datoteka.open(QIODevice::ReadWrite))
QMessageBox::information(
this,
"",
datoteka.errorString()
);
QTextStream out(&datoteka);
out << ui->tb->toPlainText();
datoteka.close();
}

void MainWindow::on_actionIzhod_triggered()
{
MainWindow::close();
}

void MainWindow::on_actionOdpri_triggered()
{
MainWindow::on_pshOdpriDatoteko_clicked();
}

void MainWindow::on_actionShrani_kot_triggered()
{
dat = QFileDialog::getSaveFileName(
this,
"Shrani datoteko kot",
"C://",
"Vse datoteke (*.*)");

QMessageBox::information(
this,
"",
dat);
QFile datoteka(dat);

if (!datoteka.open(QIODevice::WriteOnly | QIODevice::Text))
QMessageBox::information(
this,
"",
datoteka.errorString()
);

QTextStream out(&datoteka);
out << ui->tb->toPlainText();
datoteka.close();
}



.pro

#-------------------------------------------------
#
# Project created by QtCreator 2014-10-30T12:51:09
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = IBO_win_03
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += \
../../../../../IBO_win03_1/mainwindow.ui \
IBO_win03_1/mainwindow.ui

Nomad_Tech
31st October 2014, 10:14
Does " ../../../../../IBO_win03_1/mainwindow.ui" actually exist? You seem to have two 'mainwindow.ui' files in your project file

Emit
31st October 2014, 10:36
I fixed it and it works now. It seems the problem was with .ui file.

aamer4yu
31st October 2014, 12:03
Can you state what the problem was ? It may help others :)

Emit
31st October 2014, 13:34
I don' t know exactly. I deleted the .ui file and paste it again and deleted some folders that were in project directory and after that the project compiled.

Nomad_Tech
7th November 2014, 09:24
If you have the same file in two different locations, Ie: "mainwindow.ui" and "../../../../../IBO_win03_1/mainwindow.ui" listed in your project file it will not compile.