Program running no problem at the beginning, after debugging, because don't know which programs at run time after operation can produce a breakpoint, and feel is random, because a lot of places have breakpoints, tried to find online way, don't work, make up for a long time program can not run the mentality collapse suddenly orz
test. CPP code
# include "test. H"
#include
#include
#include
#include
Engine. The # include "h"
#include
#include
#include
#include
#include//define string
#include
#include
# pragma comment (lib, "libeng. Lib")
# pragma comment (lib, "libmx. Lib")
# pragma comment (lib, "libmat. Lib")
The Test: Test (QWidget * parent)//adjust the picture
: QMainWindow (parent)
{
UI. SetupUi (this);
QImage Image;
Image. The load (" E:/QT/WORK/Test/Test/1400 _01. GIF ");
QPixmap pixmap=QPixmap: : fromImage (Image);
Int with=UI. Label_6 - & gt; Width ();
Int height=UI. Label_6 - & gt; Height ();
QPixmap fitpixmap=pixmap. Scaled (with height, Qt: : IgnoreAspectRatio, Qt: : SmoothTransformation);//full fill the
//QPixmap fitpixmap=pixmap. Scaled (with height, Qt: : KeepAspectRatio, Qt: : SmoothTransformation);//scaling
UI. Label_6 - & gt; SetPixmap (fitpixmap);
}
//% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
Void Test: : on_conduct_2_clicked ()//conduct
{
//get the input parameter
QString w=UI. Label - & gt; The text ();
QString q=UI. Label - & gt; The text ();
Int QXS=q.t oInt ();
//check for input messagebox function out of an error dialog
QString aa=UI. Label_7 - & gt; The text ();
If (aa=="DJBZZ")
{
If (w.i sEmpty ())
{
MessageBoxA (NULL, "Error in intput", "Error", MB_OK);//we manually input strings are usually const char * (LPCSTR) type, so you only need to MessageBox MessageBoxA can instead of the other,
//MessageBox (NuLL, "STR", "STR", MB_OK)
//MB_OK button type
return;
}
The else
{
//check engine
Engine * ep;//the open engine
if (! (ep=engOpen (\ "0")))
{
Fprintf (stderr, "\ nCan 't start MATLAB engine \ n");
/* return; */
}
//pattern function
Int L=QXS;
Const double PI=3.1415926;
Double * t=new double [L];
Double * p=new double [L];
for (int i=0; I & lt; L; I++)
{
[I] t=2 * PI * I/L;
}
for (int i=0; I & lt; L; I++)
{
P [I]=1;
}
MxArray * T=NULL, * result=NULL;
T=mxCreateDoubleMatrix (1, 1, mxREAL);//should be A matrix of mxArray * referred to in A pointer to the memory of the application, the m is for application of rows of the matrix, n is to apply for the number of columns of the matrix
MxArray * P=NULL, * result1=NULL;
P=mxCreateDoubleMatrix (1, 1, mxREAL);
Memcpy ((void *) mxGetPr (T), T (void *), L * sizeof (T [0]));
Memcpy ((void *) mxGetPr (P), (void *) P and L * sizeof (t [0]));
EngPutVariable (ep, theta, T);//the variable in the matlab in quotation marks in
/* engPutVariable (ep, "r", P); */
EngEvalString (ep, "DJBZZ");//call m file
//engEvalString (ep, "f=sin (theta);" );
//engEvalString (ep, f=abs (f); "" );
//engEvalString (ep, "subplot (1, 2, 1);" );
//engEvalString (ep, "polar (theta, f);" );
//engEvalString (ep, "the title (' E surface pattern ');" );
//engEvalString (ep, "subplot,2,2 (1);" );
//engEvalString (ep, "polar (theta, r, 'm');" );//crosslinking c and R in the matlab variables namely according to the above process to redefine L
//engEvalString (ep, "the title (' H plane direction figure ');" );
//engEvalString (ep, "f=sin (theta); F=abs (f);" );
//engEvalString (ep, "for k=1: L r (k)=1; End ");
//engEvalString (ep, "subplot (1, 2, 1); Polar (theta, f); The title (' E plane direction figure); The title (' E plane direction figure); Subplot (1,2,2); Polar (theta, r, 'm'); Title (' H plane direction figure ');" );//can be a statement
for (int i=0; I & lt;=1000; I++)//loaded box progress load
{
UI. ProgressBar - & gt; SetValue (I);
}
UI. Label - & gt; clear();
}
}
If (aa=="jymz")
{
}
}
Void Test: : on_clean_clicked ()
{
The UI. The checkBox - & gt; SetChecked (false);
UI. CheckBox_2 - & gt; SetChecked (false);
UI. CheckBox_3 - & gt; SetChecked (false);
UI. Label - & gt; clear();
UI. Label_2 - & gt; clear();
UI. Label_3 - & gt; clear();
UI. Label_4 - & gt; clear();
UI. Label_5 - & gt; clear();
}
Void Test: : on_checkBox_clicked ()
{
}
Void Test: : on_checkBox_2_clicked ()
{
}
Void Test: : on_checkBox_3_clicked ()
{
}
//void Test: : on_push_clicked ()
//{
//aa=QString UI. Label_7 - & gt; The text ();
//if (aa=="DJBZZ")
//{
//UI. Label_4 - & gt; SetText (aa);
//}
///* UI label_4 - & gt; SetText (aa); */
//}
Void Test: : on_pushButton_clicked ()//in antenna direction function
{
Ui.com boBox - & gt; clear();
Ui.com boBox - & gt; AddItem (" DJBZZ ", 1);
Ui.com boBox - & gt; AddItem (" jymz ", 2);
Ui.com boBox - & gt; AddItem (" shiyan ", 3);
}
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull