少し助けてくれたらうれしいです。 トピックにあるので、Q_OBJECT :: connectを実行しようとするとエラーが発生します。 だから私のコードは次のとおりです。 preferences.h:このようなスロットはありませんMainWindow :: showPreferencesWindow()
#include <QDialog>
#include <QApplication>
#include <QCoreApplication>
namespace Ui {
class Preferences;
}
class Preferences : public QDialog
{
Q_OBJECT
public:
explicit Preferences(QWidget *parent = 0);
~Preferences();
private:
Ui::Preferences *ui;
};
preferences.cpp:
#include "preferences.h"
#include "ui_preferences.h"
Preferences::Preferences(QWidget *parent) :
QDialog(parent),
ui(new Ui::Preferences)
{
ui->setupUi(this);
}
Preferences::~Preferences()
{
delete ui;
}
mainwindow.h:
#include "preferences.h"
#include "addkierowca.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
Preferences *PreferencesWindow;
private:
/* some private methods */
void showPreferencesWindow();
そして最後にではなく、少なくともmainwindow.cpp:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->actionUstawiania, SIGNAL(triggered()), this, SLOT(showPreferencesWindow()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::showPreferencesWindow()
{
PreferencesWindow = new Preferences(this);
PreferencesWindow->show();
PreferencesWindow->exec();
}
私はどこにでもanwserを見つけることができませんでしたが、私はほとんど同じトピックがあることを知っていますが、それらのどれも私を助けませんでした。 アドバイスありがとうございます。
'slots:'の下にスロットを宣言しようとしましたか?なぜ人々はQt 5の6年後も古い接続構文を使用していますか? – LogicStuff