// make the dialog adjust to its layout
layout()->setSizeConstraint(QLayout::SetFixedSize); // <- this does the trick!
Страница на QtC
Ещё один вариант
// make the dialog adjust to its layout
layout()->setSizeConstraint(QLayout::SetFixedSize); // <- this does the trick!
// sz: img' resolution; idx: row index where image is stored (@img)
QImage cvMatToQImage(const CvMat *img, const CvSize sz, const size_t idx)
{
Q_ASSERT(CV_IS_MAT(img));
Q_ASSERT(img->rows > idx);
Q_ASSERT((sz.width*sz.height)==img->cols);
QImage t1(sz.width,sz.height,QImage::Format_RGB888);
const int type = CV_MAT_TYPE( img->type );
for (int i=0;i<sz.height;i++)
for(int j=0;j<sz.width;j++) {
int g=0;
switch(type) { // calculate size of single element
case CV_32FC1:
g = static_cast<int>(CV_MAT_ELEM(*img,float,idx,i*sz.width+j));
break;
case CV_8UC1:
g = static_cast<int>(CV_MAT_ELEM(*img,uchar,idx,i*sz.width+j));
break;
default:
qFatal("This is very sad T_T");
}
t1.setPixel(j,i,qRgb(g,g,g));
}
return t1;
}