нужно помочь с qt 5.12, а точнее с линковщиком. Постоянно видает ошибку, хоть что не делай(Хотя оно работало) разрядность какая нужно стоит, qmake не помогает:
*.pro
QT += core gui
QT += widgets
QT += core
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Projects
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain
version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs
deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QApplication>
#include <QMessageBox>
#include <QFile>
#include <QFileDialog>
#include <QTextStream>
#include <QString>
#include <QPushButton>
#include <QTextEdit>
using namespace std;
QString SaveToFile(const QString Path, const QString Text){
QFile file(Path);
if(!file.open(QFile::WriteOnly | QFile::Text)){
return "Path not Correct!";
}else if (Path == "File Path") {
return "Not choose file!";
}
QTextStream stream(&file);
stream << Text;
file.close();
return "Successful saved";
}
QString ReadFile(const QString Path){
QFile file(Path);
if(!file.open(QFile::ReadOnly | QFile::Text)){
return "Path not Correct";
}
QTextStream stream(&file);
QString res = stream.readAll();
file.close();
return res;
}
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->PathLabel->setReadOnly(true);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionOpen_triggered()
{
QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"),"D://");
ui->PathLabel->setText(filePath);
QString text = ReadFile(filePath);
ui->textEdit->setText(text);
}
void MainWindow::on_actionSave_triggered()
{
QString res = SaveToFile( ui->PathLabel->toPlainText(), ui->textEdit->toPlainText());
QMessageBox::information(this, "Information",res);
}
void MainWindow::on_actionCreate_triggered()
{
QString Path = QFileDialog::getSaveFileName(this, tr("Save File"),"D://", tr("*"));
QString res = SaveToFile( Path, ui->textEdit->toPlainText());
ui->PathLabel->setText(Path);
QMessageBox::information(this, "Information",res);
}
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 = nullptr);
~MainWindow();
public slots:
void on_actionOpen_triggered();
void on_actionSave_triggered();
void on_actionSave_as_triggered();
void on_actionCreate_triggered();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
MainWindow::on_actionSave_as_triggered(void)часом не объявлена, какprivate? Кстати заголовочный файл тоже было бы неплохо показать. – Bogdan Feb 04 '19 at 14:40on_actionSave_as_triggered? Вам компилятор (линкер) говорит, что не может его найти. И его действительно нет. В чем вопрос тогда? (Никакого отноошнения к private эта тема не имеет). – AnT stands with Russia Feb 04 '19 at 14:45