Results 1 to 6 of 6

Thread: No rule to make target

  1. #1
    Join Date
    Oct 2014
    Posts
    21
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default No rule to make target

    I tried to run a program but the process stops due to the error

    Qt Code:
    1. :-1: error: No rule to make target '../../../../../IBO_win03_1/mainwindow.ui', needed by 'ui_mainwindow.h'. Stop.
    To copy to clipboard, switch view to plain text mode 

    .h
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5.  
    6.  
    7. namespace Ui {
    8. class MainWindow;
    9. }
    10.  
    11. class MainWindow : public QMainWindow
    12. {
    13. Q_OBJECT
    14.  
    15. public:
    16. explicit MainWindow(QWidget *parent = 0);
    17. ~MainWindow();
    18.  
    19. private slots:
    20. void on_pshOdpriDatoteko_clicked();
    21.  
    22. void on_pshShraniDatoteko_clicked();
    23.  
    24. void on_actionIzhod_triggered();
    25.  
    26. void on_actionOdpri_triggered();
    27.  
    28. void on_actionShrani_kot_triggered();
    29.  
    30. private:
    31. Ui::MainWindow *ui;
    32.  
    33. QString dat;
    34. };
    35.  
    36. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    main
    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QApplication>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. MainWindow w;
    8. w.show();
    9.  
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    .cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include <QFileDialog>
    4. #include <QDebug>
    5. #include <QFile>
    6. #include <QTextStream>
    7. #include <QMessageBox>
    8.  
    9.  
    10. MainWindow::MainWindow(QWidget *parent) :
    11. QMainWindow(parent),
    12. ui(new Ui::MainWindow)
    13. {
    14. ui->setupUi(this);
    15. }
    16.  
    17. MainWindow::~MainWindow()
    18. {
    19. delete ui;
    20. }
    21.  
    22. void MainWindow::on_pshOdpriDatoteko_clicked()
    23. {
    24. dat = QFileDialog::getOpenFileName(
    25. this,
    26. "Odpri datoteko",
    27. "C://",
    28. "Vse datoteke (*.*)");
    29.  
    30. /*
    31.   QMessageBox::information(
    32.   this,
    33.   "",
    34.   dat);
    35.   */
    36.  
    37. QFile datoteka(dat);
    38. if (!datoteka.open(QIODevice::ReadOnly))
    39. QMessageBox::information(
    40. this,
    41. "",
    42. datoteka.errorString()
    43. );
    44. QTextStream in(&datoteka);
    45. ui->tb->setText(in.readAll());
    46. datoteka.close();
    47. }
    48.  
    49. void MainWindow::on_pshShraniDatoteko_clicked()
    50. {
    51. QFile datoteka(dat);
    52. if (!datoteka.open(QIODevice::ReadWrite))
    53. QMessageBox::information(
    54. this,
    55. "",
    56. datoteka.errorString()
    57. );
    58. QTextStream out(&datoteka);
    59. out << ui->tb->toPlainText();
    60. datoteka.close();
    61. }
    62.  
    63. void MainWindow::on_actionIzhod_triggered()
    64. {
    65. MainWindow::close();
    66. }
    67.  
    68. void MainWindow::on_actionOdpri_triggered()
    69. {
    70. MainWindow::on_pshOdpriDatoteko_clicked();
    71. }
    72.  
    73. void MainWindow::on_actionShrani_kot_triggered()
    74. {
    75. dat = QFileDialog::getSaveFileName(
    76. this,
    77. "Shrani datoteko kot",
    78. "C://",
    79. "Vse datoteke (*.*)");
    80.  
    81. QMessageBox::information(
    82. this,
    83. "",
    84. dat);
    85. QFile datoteka(dat);
    86.  
    87. if (!datoteka.open(QIODevice::WriteOnly | QIODevice::Text))
    88. QMessageBox::information(
    89. this,
    90. "",
    91. datoteka.errorString()
    92. );
    93.  
    94. QTextStream out(&datoteka);
    95. out << ui->tb->toPlainText();
    96. datoteka.close();
    97. }
    To copy to clipboard, switch view to plain text mode 

    .pro
    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2014-10-30T12:51:09
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = IBO_win_03
    12. TEMPLATE = app
    13.  
    14.  
    15. SOURCES += main.cpp\
    16. mainwindow.cpp
    17.  
    18. HEADERS += mainwindow.h
    19.  
    20. FORMS += \
    21. ../../../../../IBO_win03_1/mainwindow.ui \
    22. IBO_win03_1/mainwindow.ui
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2014
    Location
    Sydney, Australia
    Posts
    16
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: No rule to make target

    Does " ../../../../../IBO_win03_1/mainwindow.ui" actually exist? You seem to have two 'mainwindow.ui' files in your project file
    "When the only tool you have is a hammer, every problem resembles a nail"

  3. #3
    Join Date
    Oct 2014
    Posts
    21
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: No rule to make target

    I fixed it and it works now. It seems the problem was with .ui file.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: No rule to make target

    Can you state what the problem was ? It may help others

  5. The following user says thank you to aamer4yu for this useful post:

    Nomad_Tech (7th November 2014)

  6. #5
    Join Date
    Oct 2014
    Posts
    21
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: No rule to make target

    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.

  7. #6
    Join Date
    Sep 2014
    Location
    Sydney, Australia
    Posts
    16
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: No rule to make target

    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.
    "When the only tool you have is a hammer, every problem resembles a nail"

Similar Threads

  1. :-1: error: No rule to make target
    By quakig in forum Newbie
    Replies: 1
    Last Post: 8th December 2013, 00:16
  2. :: error: No rule to make target
    By kurrachow in forum Newbie
    Replies: 2
    Last Post: 15th March 2011, 13:33
  3. Replies: 1
    Last Post: 5th March 2011, 18:23
  4. No rule to make target
    By Coolname007 in forum Qt Programming
    Replies: 6
    Last Post: 4th March 2011, 20:08
  5. No rule to make target?
    By walsha3000 in forum Qt Programming
    Replies: 1
    Last Post: 2nd July 2010, 05:42

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.