我有两个功能,其中一个调用另一个。我想将其中一个用作按钮中信号 clicked() 的插槽,因此这是我的 planevolume.h 代码的一部分,因此您可以理解:
#ifndef PLANEVOLUME_H
#define PLANEVOLUME_H
#include <QMainWindow>
namespace Ui {
class planevolume;
}
//more stuff here
class planevolume : public QMainWindow {
Q_OBJECT
public:
planevolume(QWidget *parent = 0);
~planevolume();
protected:
void changeEvent(QEvent *e);
private:
Ui::planevolume *ui;
//more stuff here
public slots:
void AlignXAxis(int xmin, int xmax, vtkImagePlaneWidget* planeX);
void AlignCamera(vtkImagePlaneWidget* current_widget);
};
#endif // PLANEVOLUME_H
我会在这里放一些我的planevolume.cpp,这样你就可以理解我在它之后遇到的错误是什么。
#include <qwidget.h>
#include <qaction.h>
#include <qobject.h>
//more includes
// Define AlignCamera
void planevolume::AlignCamera(vtkImagePlaneWidget* current_widget)
{
//regular statements of a function
vtkCamera *camera=ren->GetActiveCamera();
camera->SetViewUp(vx, vy, vz);
camera->SetFocalPoint(cx, cy, cz);
camera->SetPosition(px, py, pz);
camera->OrthogonalizeViewUp();
ren->ResetCameraClippingRange();
renWin->Render();
}
// Define the action of AlignXAxis
void planevolume::AlignXAxis(int xmin, int xmax, vtkImagePlaneWidget* planeX)
{
//regular statements of a function
vtkImagePlaneWidget *current_widget= planeX;
ui->horizontalScrollBar->setValue(slice_number);
ui->horizontalScrollBar->setMinimum(xmin);
ui->horizontalScrollBar->setMaximum(xmax);
AlignCamera(current_widget);//here I call the other one
}
planevolume::planevolume(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::planevolume)
{
ui->setupUi(this);
//regular stuff
//I think here is the problem when i make the connect
connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(AlignXAxis(int, int, vtkImagePlaneWidget)));
// Start the initialization and rendering
renWin->Render();
//iren->Initialize();
//iren->Start();
// Assign the rendering window to the qvtkwidget
ui->qvtkWidget->SetRenderWindow(renWin);
}
所以它们可以编译,但是当我单击按钮时,它只会在应用程序的输出中显示:
Object::connect: 没有这样的插槽 planevolume::AlignXAxis(int, int, vtkImagePlaneWidget) in planevolume.cpp:386 Object::connect: (sender name: 'pushButton') Object::connect: (receiver name: 'planevolume' )
所以如果有人知道我做错了什么,请给我一些提示或其他东西,因为这让我发疯。:)