update layout to better fit
This commit is contained in:
@@ -35,19 +35,15 @@ void VideoViewerWidget::initGStreamer()
|
||||
void VideoViewerWidget::setupUI()
|
||||
{
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
mainLayout->setSpacing(5);
|
||||
|
||||
// Video display container
|
||||
QGroupBox* videoGroup = new QGroupBox("Video Display", this);
|
||||
QVBoxLayout* videoLayout = new QVBoxLayout();
|
||||
|
||||
// Video display - no GroupBox for maximum space
|
||||
m_videoDisplay = new QLabel(this);
|
||||
m_videoDisplay->setMinimumSize(640, 480);
|
||||
m_videoDisplay->setStyleSheet("background-color: black;");
|
||||
m_videoDisplay->setStyleSheet("background-color: black; border: 1px solid #666;");
|
||||
m_videoDisplay->setAlignment(Qt::AlignCenter);
|
||||
m_videoDisplay->setScaledContents(true); // Enable scaling for zoom later
|
||||
|
||||
videoLayout->addWidget(m_videoDisplay);
|
||||
videoGroup->setLayout(videoLayout);
|
||||
m_videoDisplay->setScaledContents(false); // Disable for better aspect ratio control
|
||||
|
||||
// Controls
|
||||
QGroupBox* controlGroup = new QGroupBox("Viewer Controls", this);
|
||||
@@ -95,7 +91,8 @@ void VideoViewerWidget::setupUI()
|
||||
controlLayout->addWidget(m_statusLabel);
|
||||
controlGroup->setLayout(controlLayout);
|
||||
|
||||
mainLayout->addWidget(videoGroup, 1);
|
||||
// Add to main layout: video takes most space, controls at bottom
|
||||
mainLayout->addWidget(m_videoDisplay, 1);
|
||||
mainLayout->addWidget(controlGroup);
|
||||
|
||||
setLayout(mainLayout);
|
||||
@@ -413,7 +410,10 @@ void VideoViewerWidget::displayFrame(const QImage& frame)
|
||||
firstFrame = false;
|
||||
}
|
||||
|
||||
// Convert QImage to QPixmap and display in label
|
||||
// Convert QImage to QPixmap and scale to fit label while keeping aspect ratio
|
||||
QPixmap pixmap = QPixmap::fromImage(frame);
|
||||
m_videoDisplay->setPixmap(pixmap.scaled(m_videoDisplay->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
QPixmap scaledPixmap = pixmap.scaled(m_videoDisplay->size(),
|
||||
Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
m_videoDisplay->setPixmap(scaledPixmap);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user