SOLVED: Qt button assign command
-
I'm using qt creator to create a gui for an vtk aplication.
I've made a #define action and I want to assign that command to a QPushButton.
How do I make the button reproduce my define if pressed?
example. ui->pushButton->...
Or if anyone knows a way to define an action in a different way than #define
-
you can create your signal/slot connection either with the designer directly or you have to use the connect() function QObject. For more information please check the manual of QObject
-
having this
@
#define AlignXAxis();
{
int slice_number;
int po = planeX->GetPlaneOrientation();
if (po == 3)
{
planeX->SetPlaneOrientationToXAxes();
slice_number = (xmax-xmin)/2;
planeX->SetSliceIndex(slice_number);
}
else
{
slice_number = planeX->GetSliceIndex();
}current_widget= planeX; ui->horizontalScrollBar->setValue(slice_number); ui->horizontalScrollBar->setMinimum(xmin); ui->horizontalScrollBar->setMaximum(xmax); AlignCamera(); }
@
it would be something like this?
@
ui->pushButton->connect(SIGNAL(clicked()),SLOT(AlignXAxis()));
@
or this?
@
connect(pushButton,SIGNAL(clicked()),SLOT(AlignXAxis()));
@
i'm sorry, i'm real new at Qt.[Edit: Added @ tags for code formatting -- mlong]
-
Do you know this document, if not please read it first.
It's fundamental for develoing with qt.