Trouble building Qt
-
Try clean and re-build / run qmake again. Alternatively delete build folder.
That should fix this in most cases.Just to be sure: Is your
UI
from typeUi::MainWindow
orUi::ImageReader
? Therefore show your header and your*.pro
file please. Also better post code as code block not as image -
@Pl45m4 Thanks for your reply! I've tried to clean and rebuild but I got this error
:-1: error: No rule to make target '/usr/lib/qt5/bin/uic', needed by 'ui_ImageReader.h'. Stop.
here is my simple code:
#ifndef IMAGEREADER_H #define IMAGEREADER_H #include <QMainWindow> #include <memory> QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow() = default; private: std::unique_ptr<Ui::MainWindow> ui; }; #endif // IMAGEREADER_H
cpp:
#include "ImageReader.h" #include "ui_ImageReader.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); }
The objectName of the ui is MainWindow
.pro file
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ ImageReader.cpp \ main.cpp HEADERS += \ ImageReader.h FORMS += \ ImageReader.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target
-
Hi,
Did you just rename the files after having created them ? If so, that is not a good idea.
-
@SGaist
I'm using Ubuntu 20.04 and I have installed qt5, I created a new empty project and I got this error again::-1: error: No rule to make target '/usr/lib/qt5/bin/uic', needed by 'ui_mainwindow.h'. Stop.
something is wrong with my installation right?
-
@SGaist I restarted from scratch, deleted the build folder and created a new project. I ran qmake first and tried to build the project but this time I got this error:
qt.qpa.xcb: could not connect to display qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
I just installed the xcb dependency and it built correctly. I still dont know/understand why I got the first error with the ui file?