I have following layouts:
when I stretch the window, the size becomes like this:
Is there a way to set the widgets in qgridlayout with the same size when the qgridlayout size changes ?
Thanks.
UPDATE
The widget in qgridlayout:
#ifndef CVIMAGEWIDGET_H
#define CVIMAGEWIDGET_H
#include <QWidget>
#include <QImage>
#include <QPainter>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QMainWindow>
class CVImageWidget : public QGraphicsView
{
Q_OBJECT
public:
explicit CVImageWidget(QMainWindow *GUIWindow, QWidget *parent = 0);
void drawBoarder(bool flag);
void showImage(const QImage& image);
void SetCameraID(int camID);
int GetCameraID();
void closeDisplay();
~CVImageWidget();
private:
QGraphicsScene *scene_;
int camera_id_;
public slots:
void resizeEvent(QResizeEvent *event);
};
#endif // CVIMAGEWIDGET_H
CPP file
#include "cvimagewidget.h"
#include <QMouseEvent>
#include <iostream>
CVImageWidget::CVImageWidget(QMainWindow *GUIWindow, QWidget *parent) : QGraphicsView(parent)
{
scene_ = new QGraphicsScene(parent);
scene_->setSceneRect(this->sceneRect());
this->setScene(scene_);
this->installEventFilter(GUIWindow);
this->setStyleSheet( "CVImageWidget { border-color: rgb(125,125,116); border-width: 3px; border-style: solid;}");
// this->setMinimumSize(136, 114);
camera_id_ = -1;
}
void CVImageWidget::showImage(const QImage& image) {
if(!image.isNull()){
scene_->clear();
scene_->addPixmap(QPixmap::fromImage(image));
}
}
void CVImageWidget::closeDisplay()
{
scene_->clear();
}
void CVImageWidget::SetCameraID(int camID)
{
camera_id_ = camID;
}
int CVImageWidget::GetCameraID()
{
return camera_id_;
}
void CVImageWidget::resizeEvent(QResizeEvent *event)
{
this->fitInView(this->sceneRect(), Qt::IgnoreAspectRatio);
QGraphicsView::resizeEvent(event);
}
void CVImageWidget::drawBoarder(bool flag)
{
if(flag)
{
this->setStyleSheet( "CVImageWidget { border-color: rgb(0,255,0); border-width: 3px; border-style: solid;}");
}else
{
this->setStyleSheet( "CVImageWidget { border-color: rgb(125,125,116); border-width: 3px; border-style: solid;}");
}
}
CVImageWidget::~CVImageWidget()
{
delete scene_;
}