Qt는 존재하는 신호를 볼 수 없습니다. Qt는 그런 신호가 없지만 그것은 존재합니다.
나는 자식 창을 열어 메인 창을 가지고 있고, 그에 대한 연결 문은 절대적으로 잘 작동 :mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "addstaffform.h"
#include "stafflist.h"
#include "editstaffwindow.h"
#include <QDialog>
#include <QString>
#include <QList>
#include "person.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_btn_add_clicked();
void refreshStaffList();
void receiveData(Person& newPerson);
void receiveEditedPerson(Person &editedPerson, int index);
void updateDeleteEnabled();
void updateEditEnabled();
void on_btn_delete_staff_clicked();
void on_btn_staff_edit_clicked();
private:
Ui::MainWindow *ui;
QString s;
QMainWindow *newWin;
QMainWindow *editStaffWin;
StaffList *m_staffList;
QList<Person> m_personList;
Person m_person;
};
#endif // MAINWINDOW_H
전혀 작동하지 mainwindow.cpp에있어서, 문제점 : addstaffwindow.h에
void MainWindow::on_btn_add_clicked()
{
//Open the add staff window, which is a form
newWin = new AddStaffWindow(this);
//connect the signal from the new form to the slot in this window to receive the person object
connect(newWin, SIGNAL(sendData(Person&)), this, SLOT(receiveData(Person&)));
newWin->show();
}
신호 (newwin을 인스턴스화)
signals:
void sendData(Person &p);
이제 편집 양식 (editStaffWin)에서 신호가 생겼고 Q_OBJECT가 확실히 거기에 있고, 정리되고, QMake를 실행하고 여러 번 빌드했는지 확인했지만 신호가 없다고 생각합니다. 존재합니다.
editstaffwindow.h 편집을 위해 mainwindow.cpp에서
signals:
void sendPerson(Person &, int index);
따라서는, sendPerson (사람 &, INT)는 표시되지 않습니다 :
void MainWindow::on_btn_staff_edit_clicked()
{
//Get the index of the widget
int index = ui->lst_staff->currentRow();
int size = ui->lst_staff->count();
if (index > -1 && index <= size)
{
//get from staff list
m_person = m_staffList->getStaffAt(index);
editStaffWin = new EditStaffWindow(this, m_person, index);
connect(editStaffWin, SIGNAL(sendPerson(Person &, int)), this, SLOT(receiveEditedPerson(Person&,int)));
editStaffWin->show();
}
}
어떤 아이디어 왜? 나는 그들 중 누구에게도 다른 것을하지 않고있다.
편집 : 전체 EditStaffWindow 헤더 :
#ifndef EDITSTAFFWINDOW_H
#define EDITSTAFFWINDOW_H
#include <QMainWindow>
#include "mainwindow.h"
#include "person.h"
#include <QObject>
namespace Ui {
class EditStaffWindow;
}
class EditStaffWindow : public QMainWindow
{
Q_OBJECT
public:
explicit EditStaffWindow(QWidget *parent, Person &p, int index);
~EditStaffWindow();
signals:
void sendPerson(Person &, int index);
private:
Ui::EditStaffWindow *ui;
Person m_person;
int m_index;
public slots:
void showData(Person &p, int index);
private slots:
void on_btn_save_clicked();
void on_btn_cancel_clicked();
};
#endif // EDITSTAFFWINDOW_H
사용중인 Qt 버전은 무엇입니까? 5 일 경우 컴파일 시간 오류가 발생하는 새로운 연결 구문을 시도하십시오. – dtech
정확한 오류 메시지는 무엇입니까? 'EditStaffWindow' 헤더도 표시 할 수 있습니까? – BartoszKP
그뿐만 아니라 (나는 5.3을 사용하고있다.) 그러나 editStaffWin ::에 대해서는 아무 것도 제안되지 않았다. 어떤 신호가 editStaffWin –