Designerで接続を作成した後、スロットの機能を変更しようとしました。そして、私はそのプライベートスロットを宣言し、それを初期化し、ビルドプログラムが実行されているが接続がうまくいきません。これは、自動にQtの dl.hQt 5デザイナQObject :: connect:そのようなスロットはありませんQDialog
#ifndef DL_H
#define DL_H
#include <QDialog>
namespace Ui {
class Dl;
}
class Dl : public QDialog
{
Q_OBJECT
public:
explicit Dl(QWidget *parent = 0);
~Dl();
private:
Ui::Dl *ui;
private slots:
void print_shit();
};
#endif
dl.cpp
#include "dl.h"
#include "ui_dl.h"
#include <iostream>
Dl::Dl(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dl)
{
ui->setupUi(this);
}
Dl::~Dl()
{
delete ui;
}
void Dl::print_shit(){
}
main.cppに
#include <QApplication>
#include <QQmlApplicationEngine>
#include "ui_dl.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Ui_Dl * dialog = new Ui_Dl;
QDialog *wnd = new QDialog();
dialog->setupUi(wnd);
wnd->show();
return app.exec();
}
#ifndef UI_DL_H
#define UI_DL_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QDialog>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QSlider>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_Dl
{
public:
QWidget *layoutWidget;
QGridLayout *gridLayout;
QHBoxLayout *horizontalLayout_2;
QPushButton *pushButton_6;
QPushButton *knopka;
QHBoxLayout *horizontalLayout;
QPushButton *pushButton;
QPushButton *pushButton_2;
QPushButton *pushButton_3;
QHBoxLayout *horizontalLayout_3;
QPushButton *pushButton_8;
QPushButton *pushButton_7;
QPushButton *pushButton_9;
QSpinBox *spinBox;
QSlider *horizontalSlider;
void setupUi(QDialog *Dl)
{
if (Dl->objectName().isEmpty())
Dl->setObjectName(QStringLiteral("Dl"));
Dl->setWindowModality(Qt::NonModal);
Dl->resize(705, 504);
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(Dl->sizePolicy().hasHeightForWidth());
Dl->setSizePolicy(sizePolicy);
QPalette palette;
QBrush brush(QColor(0, 0, 0, 255));
brush.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::WindowText, brush);
QBrush brush1(QColor(153, 240, 185, 255));
brush1.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::Button, brush1);
QBrush brush2(QColor(255, 255, 255, 255));
brush2.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::Light, brush2);
QBrush brush3(QColor(204, 247, 220, 255));
brush3.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::Midlight, brush3);
QBrush brush4(QColor(76, 120, 92, 255));
brush4.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::Dark, brush4);
QBrush brush5(QColor(102, 160, 123, 255));
brush5.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::Mid, brush5);
palette.setBrush(QPalette::Active, QPalette::Text, brush);
palette.setBrush(QPalette::Active, QPalette::BrightText, brush2);
palette.setBrush(QPalette::Active, QPalette::ButtonText, brush);
palette.setBrush(QPalette::Active, QPalette::Base, brush2);
palette.setBrush(QPalette::Active, QPalette::Window, brush1);
palette.setBrush(QPalette::Active, QPalette::Shadow, brush);
palette.setBrush(QPalette::Active, QPalette::AlternateBase, brush3);
QBrush brush6(QColor(255, 255, 220, 255));
brush6.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::ToolTipBase, brush6);
palette.setBrush(QPalette::Active, QPalette::ToolTipText, brush);
palette.setBrush(QPalette::Inactive, QPalette::WindowText, brush);
palette.setBrush(QPalette::Inactive, QPalette::Button, brush1);
palette.setBrush(QPalette::Inactive, QPalette::Light, brush2);
palette.setBrush(QPalette::Inactive, QPalette::Midlight, brush3);
palette.setBrush(QPalette::Inactive, QPalette::Dark, brush4);
palette.setBrush(QPalette::Inactive, QPalette::Mid, brush5);
palette.setBrush(QPalette::Inactive, QPalette::Text, brush);
palette.setBrush(QPalette::Inactive, QPalette::BrightText, brush2);
palette.setBrush(QPalette::Inactive, QPalette::ButtonText, brush);
palette.setBrush(QPalette::Inactive, QPalette::Base, brush2);
palette.setBrush(QPalette::Inactive, QPalette::Window, brush1);
palette.setBrush(QPalette::Inactive, QPalette::Shadow, brush);
palette.setBrush(QPalette::Inactive, QPalette::AlternateBase, brush3);
palette.setBrush(QPalette::Inactive, QPalette::ToolTipBase, brush6);
palette.setBrush(QPalette::Inactive, QPalette::ToolTipText, brush);
palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush4);
palette.setBrush(QPalette::Disabled, QPalette::Button, brush1);
palette.setBrush(QPalette::Disabled, QPalette::Light, brush2);
palette.setBrush(QPalette::Disabled, QPalette::Midlight, brush3);
palette.setBrush(QPalette::Disabled, QPalette::Dark, brush4);
palette.setBrush(QPalette::Disabled, QPalette::Mid, brush5);
palette.setBrush(QPalette::Disabled, QPalette::Text, brush4);
palette.setBrush(QPalette::Disabled, QPalette::BrightText, brush2);
palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush4);
palette.setBrush(QPalette::Disabled, QPalette::Base, brush1);
palette.setBrush(QPalette::Disabled, QPalette::Window, brush1);
palette.setBrush(QPalette::Disabled, QPalette::Shadow, brush);
palette.setBrush(QPalette::Disabled, QPalette::AlternateBase, brush1);
palette.setBrush(QPalette::Disabled, QPalette::ToolTipBase, brush6);
palette.setBrush(QPalette::Disabled, QPalette::ToolTipText, brush);
Dl->setPalette(palette);
Dl->setCursor(QCursor(Qt::ArrowCursor));
Dl->setAutoFillBackground(false);
Dl->setSizeGripEnabled(true);
layoutWidget = new QWidget(Dl);
layoutWidget->setObjectName(QStringLiteral("layoutWidget"));
layoutWidget->setGeometry(QRect(140, 90, 421, 351));
gridLayout = new QGridLayout(layoutWidget);
gridLayout->setObjectName(QStringLiteral("gridLayout"));
gridLayout->setContentsMargins(0, 0, 0, 0);
horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
horizontalLayout_2->setSizeConstraint(QLayout::SetNoConstraint);
pushButton_6 = new QPushButton(layoutWidget);
pushButton_6->setObjectName(QStringLiteral("pushButton_6"));
sizePolicy.setHeightForWidth(pushButton_6->sizePolicy().hasHeightForWidth());
pushButton_6->setSizePolicy(sizePolicy);
pushButton_6->setMaximumSize(QSize(191, 103));
pushButton_6->setMouseTracking(false);
pushButton_6->setAcceptDrops(false);
pushButton_6->setAutoFillBackground(false);
pushButton_6->setStyleSheet(QStringLiteral("border-image: url(:/new/prefix1/lico);"));
pushButton_6->setCheckable(false);
pushButton_6->setAutoRepeat(false);
pushButton_6->setAutoExclusive(false);
pushButton_6->setAutoDefault(true);
pushButton_6->setFlat(false);
horizontalLayout_2->addWidget(pushButton_6);
knopka = new QPushButton(layoutWidget);
knopka->setObjectName(QStringLiteral("knopka"));
knopka->setEnabled(true);
sizePolicy.setHeightForWidth(knopka->sizePolicy().hasHeightForWidth());
knopka->setSizePolicy(sizePolicy);
knopka->setSizeIncrement(QSize(0, 0));
knopka->setMouseTracking(false);
knopka->setAutoFillBackground(false);
knopka->setStyleSheet(QStringLiteral(""));
knopka->setCheckable(false);
knopka->setAutoDefault(true);
knopka->setFlat(false);
horizontalLayout_2->addWidget(knopka);
gridLayout->addLayout(horizontalLayout_2, 1, 0, 1, 1);
horizontalLayout = new QHBoxLayout();
horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
horizontalLayout->setSizeConstraint(QLayout::SetNoConstraint);
pushButton = new QPushButton(layoutWidget);
pushButton->setObjectName(QStringLiteral("pushButton"));
QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(pushButton->sizePolicy().hasHeightForWidth());
pushButton->setSizePolicy(sizePolicy1);
pushButton->setMouseTracking(false);
pushButton->setCheckable(false);
horizontalLayout->addWidget(pushButton);
pushButton_2 = new QPushButton(layoutWidget);
pushButton_2->setObjectName(QStringLiteral("pushButton_2"));
sizePolicy1.setHeightForWidth(pushButton_2->sizePolicy().hasHeightForWidth());
pushButton_2->setSizePolicy(sizePolicy1);
pushButton_2->setMinimumSize(QSize(125, 104));
pushButton_2->setMouseTracking(false);
pushButton_2->setCheckable(false);
horizontalLayout->addWidget(pushButton_2);
pushButton_3 = new QPushButton(layoutWidget);
pushButton_3->setObjectName(QStringLiteral("pushButton_3"));
sizePolicy.setHeightForWidth(pushButton_3->sizePolicy().hasHeightForWidth());
pushButton_3->setSizePolicy(sizePolicy);
pushButton_3->setMouseTracking(false);
pushButton_3->setCheckable(false);
horizontalLayout->addWidget(pushButton_3);
gridLayout->addLayout(horizontalLayout, 0, 0, 1, 1);
horizontalLayout_3 = new QHBoxLayout();
horizontalLayout_3->setObjectName(QStringLiteral("horizontalLayout_3"));
horizontalLayout_3->setSizeConstraint(QLayout::SetNoConstraint);
pushButton_8 = new QPushButton(layoutWidget);
pushButton_8->setObjectName(QStringLiteral("pushButton_8"));
sizePolicy1.setHeightForWidth(pushButton_8->sizePolicy().hasHeightForWidth());
pushButton_8->setSizePolicy(sizePolicy1);
pushButton_8->setMouseTracking(false);
pushButton_8->setStyleSheet(QString::fromUtf8("border-image: url(C:/Users/Acer/Pictures/Screenshot \320\273\320\270\321\206\320\276(\320\260\320\262\320\260\321\202\320\260\321\200).png);"));
pushButton_8->setCheckable(false);
horizontalLayout_3->addWidget(pushButton_8);
pushButton_7 = new QPushButton(layoutWidget);
pushButton_7->setObjectName(QStringLiteral("pushButton_7"));
sizePolicy1.setHeightForWidth(pushButton_7->sizePolicy().hasHeightForWidth());
pushButton_7->setSizePolicy(sizePolicy1);
pushButton_7->setMouseTracking(false);
pushButton_7->setStyleSheet(QStringLiteral("border-image: url(:/new/prefix1/lico);"));
pushButton_7->setCheckable(false);
horizontalLayout_3->addWidget(pushButton_7);
pushButton_9 = new QPushButton(layoutWidget);
pushButton_9->setObjectName(QStringLiteral("pushButton_9"));
sizePolicy.setHeightForWidth(pushButton_9->sizePolicy().hasHeightForWidth());
pushButton_9->setSizePolicy(sizePolicy);
pushButton_9->setMouseTracking(false);
pushButton_9->setCheckable(false);
horizontalLayout_3->addWidget(pushButton_9);
gridLayout->addLayout(horizontalLayout_3, 2, 0, 1, 1);
spinBox = new QSpinBox(Dl);
spinBox->setObjectName(QStringLiteral("spinBox"));
spinBox->setGeometry(QRect(590, 250, 101, 121));
horizontalSlider = new QSlider(Dl);
horizontalSlider->setObjectName(QStringLiteral("horizontalSlider"));
horizontalSlider->setGeometry(QRect(470, 470, 160, 22));
horizontalSlider->setOrientation(Qt::Horizontal);
retranslateUi(Dl);
QObject::connect(knopka, SIGNAL(clicked()), Dl, SLOT(print_shit()));
QMetaObject::connectSlotsByName(Dl);
} // setupUi
void retranslateUi(QDialog *Dl)
{
Dl->setWindowTitle(QApplication::translate("Dl", "Dialog", 0));
pushButton_6->setText(QApplication::translate("Dl", "\320\243\320\272\321\200\320\260\320\270\320\275\320\260", 0));
knopka->setText(QApplication::translate("Dl", "\320\234\320\270\321\201\321\202\320\265\321\200 \320\264\321\203\320\264\320\265\321\206", 0));
pushButton->setText(QApplication::translate("Dl", "\320\257 \320\265\320\261\321\203 \321\201\320\276\320\261\320\260\320\272", 0));
#ifndef QT_NO_TOOLTIP
pushButton_2->setToolTip(QApplication::translate("Dl", "<html><head/><body><p><br/></p></body></html>", 0));
#endif // QT_NO_TOOLTIP
pushButton_2->setText(QApplication::translate("Dl", "\320\242\321\200\320\260\320\274\320\277", 0));
pushButton_3->setText(QApplication::translate("Dl", "\320\234\320\270\321\201\321\202\321\200\320\265 \320\264\321\203\320\264\320\265\321\206", 0));
pushButton_8->setText(QApplication::translate("Dl", "\320\242\321\200\320\260\320\274\320\277", 0));
pushButton_7->setText(QApplication::translate("Dl", "\320\243\320\272\321\200\320\260\320\270\320\275\320\260", 0));
pushButton_9->setText(QApplication::translate("Dl", "\320\257 \320\265\320\261\321\203 \321\201\320\276\320\261\320\260\320\272", 0));
} // retranslateUi
};
namespace Ui {
class Dl: public Ui_Dl {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_DL_H
によって生成された私は、問題はui_dl.hにすることができると思い
QObject::connect: No such slot QDialog
語ります