Discord widget using Qt
-
wrote on 19 Oct 2022, 04:38 last edited by Ylvy
-
Is it possible to build the discord widget using any qt widget? or do i need to write a lib for this?
-
Hi,
Depending on your goal, you might want to consider QtWebView to show that widget directly.
-
Hi,
Depending on your goal, you might want to consider QtWebView to show that widget directly.
wrote on 19 Oct 2022, 17:49 last edited by Ylvy@SGais My goal is to display the premade widget from discord, do you think it would work using
QtWebView
?I'm trying to compile
QtWebView
from the source, but it ain't working, do you know if this plugin doesn't compile as static? -
It's a JavaScript based widget so you need a browser widget. On desktop it usually means QtWebEngine (QtWebView uses QtWebEngine on platforms without system provided webview) so no, static build is not an option as web engine does not build statically (nothing to do with Qt).
-
It's a JavaScript based widget so you need a browser widget. On desktop it usually means QtWebEngine (QtWebView uses QtWebEngine on platforms without system provided webview) so no, static build is not an option as web engine does not build statically (nothing to do with Qt).
wrote on 19 Oct 2022, 19:55 last edited by YlvyThis is working:
#include <QWebEngineView> int main(int argc, char *argv[]) { QApplication app(argc, argv); QWebEngineView view; view.setHtml(R"(<iframe src="https://discord.com/widget?id=723331111111505017&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>)"); view.resize(350, 500); view.show(); return app.exec(); }
When i load it into QMainWindow its not being shown:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); QWidget* widget = new QWidget(ui->centralwidget); widget->setObjectName("test"); widget->setGeometry(10, 10, 350, 500); widget->setStyleSheet("#test { background-color: black; }"); QWebEngineView view; view.setHtml(R"(<iframe src="https://discord.com/widget?id=723331111111505017&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>)"); view.setGeometry(10, 10, 350, 350); view.resize(350, 500); view.show(); QGridLayout* lay = new QGridLayout(); widget->setLayout(lay); lay->addWidget(&view); widget->show(); view.show(); }
-
This is working:
#include <QWebEngineView> int main(int argc, char *argv[]) { QApplication app(argc, argv); QWebEngineView view; view.setHtml(R"(<iframe src="https://discord.com/widget?id=723331111111505017&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>)"); view.resize(350, 500); view.show(); return app.exec(); }
When i load it into QMainWindow its not being shown:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); QWidget* widget = new QWidget(ui->centralwidget); widget->setObjectName("test"); widget->setGeometry(10, 10, 350, 500); widget->setStyleSheet("#test { background-color: black; }"); QWebEngineView view; view.setHtml(R"(<iframe src="https://discord.com/widget?id=723331111111505017&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>)"); view.setGeometry(10, 10, 350, 350); view.resize(350, 500); view.show(); QGridLayout* lay = new QGridLayout(); widget->setLayout(lay); lay->addWidget(&view); widget->show(); view.show(); }
wrote on 19 Oct 2022, 21:24 last edited by@Ylvy said in Discord widget using Qt:
QWebEngineView view;
This is a local/stack variable, it is destroyed at the end of the constructor.
-
It's a JavaScript based widget so you need a browser widget. On desktop it usually means QtWebEngine (QtWebView uses QtWebEngine on platforms without system provided webview) so no, static build is not an option as web engine does not build statically (nothing to do with Qt).
wrote on 20 Oct 2022, 05:36 last edited bySGaist said in Discord widget using Qt:
It's a JavaScript based widget so you need a browser widget. On desktop it usually means QtWebEngine (QtWebView uses QtWebEngine on platforms without system provided webview) so no, static build is not an option as web engine does not build statically (nothing to do with Qt).
@SGaist I'm building my qt app with the static source, so it's not possible to use the
webenginewidgets
module?
5/8