के माध्यम से क्यूटी परियोजना को कार्यान्वित करना मैं .pro फ़ाइल के माध्यम से क्यूके के माध्यम से क्यूटी के बहुत सरल और मूल उदाहरण को चलाने और चलाने की कोशिश कर रहा हूं। निम्नलिखित क्यूटी परियोजना (क्यूटी परियोजना स्वचालित रूप से उत्पन्न के लिए निर्देशिका संरचना के लिए कोडसीएमके
Cmake (my project name)
├── headers
│ └── mainwindow.h
├── sources
│ ├── main.cpp
│ └── mainwindow.cpp
└── 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:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
main.cpp है
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
यह मेरा CmakeLists.txt है
project(Cmake)
find_package(Qt5Widgets)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
QT5_WRAP_CPP(Cmake_hdr_moc mainwindow.h)
QT5_WRAP_UI(Cmake_form_hdr mainwindow.ui)
add_library(mainwindow ${Cmake_hdr_moc} ${Cmake_form_hdr})
qt5_use_modules(mainwindow Widgets)
add_executable(Cmake main.cpp mainwindow)
qt5_use_modules(Cmake Core Gui Widgets)
mainwindow.ui
<?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>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>29</height>
</rect>
</property>
</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>
जब मैं परियोजना का निर्माण और CMake चलाने के लिए, यह ui_mainwindow.h 'ऐसी कोई फाइल नहीं संकेत mainwindow.h दायर करने के लिए कहते हैं या निर्देशिका।
आपकी * .ui फ़ाइल कौन है? – Gluttton
मैंने पोस्ट को .ui फ़ाइल के साथ संपादित किया है। अब तक मैंने उस फ़ाइल में कोई भी बदलाव नहीं किया है, यह स्वचालित रूप से जेनरेट की गई फ़ाइल है। – user3877872
क्या आप आईडीई में या फाइल सिस्टम में अपनी परियोजना की संरचना दिखाते हैं? – Gluttton