diff --git a/source/ui/ui-obs-browser-widget.cpp b/source/ui/ui-obs-browser-widget.cpp index 472c9059..78445ed8 100644 --- a/source/ui/ui-obs-browser-widget.cpp +++ b/source/ui/ui-obs-browser-widget.cpp @@ -13,6 +13,9 @@ #include #include #endif + +#include +#include #include "warning-enable.hpp" streamfx::ui::obs_browser_cef::obs_browser_cef() @@ -70,23 +73,28 @@ std::shared_ptr streamfx::ui::obs_browser_cef::in streamfx::ui::obs_browser_widget::obs_browser_widget(QUrl url, QWidget* parent) : QWidget(parent) { + // Create Layout + auto layout = new QGridLayout(this); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + // Create CEF Widget _cef = obs_browser_cef::instance(); _widget = reinterpret_cast(_cef->cef()) ->create_widget(this, url.toString().toStdString(), reinterpret_cast(_cef->cookie_manager())); if (!_widget) { - throw std::runtime_error("Failed to create QCefWidget."); + throw std::runtime_error("Failed to create CEF Widget."); } - - // Add a proper layout. - _layout = new QHBoxLayout(); - _layout->setContentsMargins(0, 0, 0, 0); - _layout->setSpacing(0); - this->setLayout(_layout); - _layout->addWidget(_widget); - - // Disable all popups. dynamic_cast(_widget)->allowAllPopups(false); + _widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + layout->addWidget(_widget, 0, 0); + + // This fixes a strange issue where Qt just does not update the size of the QCefWidget. + // I do not know why this is, all I know is that this is absolutely necessary for QCefWidget. + auto test = new QWidget(this); + test->setFixedSize(0, 0); + layout->addWidget(test, 1, 0); } streamfx::ui::obs_browser_widget::~obs_browser_widget() {} diff --git a/source/ui/ui-obs-browser-widget.hpp b/source/ui/ui-obs-browser-widget.hpp index a483f706..176a9dd5 100644 --- a/source/ui/ui-obs-browser-widget.hpp +++ b/source/ui/ui-obs-browser-widget.hpp @@ -6,8 +6,6 @@ #include "util/util-library.hpp" #include "warning-disable.hpp" -#include -#include #include #include #include "warning-enable.hpp" @@ -38,7 +36,6 @@ namespace streamfx::ui { std::shared_ptr _cef; QWidget* _widget; - QHBoxLayout* _layout; public: obs_browser_widget(QUrl url, QWidget* parent = nullptr);