Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Discord widget using Qt
Forum Updated to NodeBB v4.3 + New Features

Discord widget using Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 815 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Ylvy
    wrote on 19 Oct 2022, 04:38 last edited by Ylvy
    #1

    Is it possible to build the discord widget using any qt widget? or do i need to write a lib for this?

    Discord_2022-10-19_01-36-02.png

    J 1 Reply Last reply 19 Oct 2022, 07:56
    0
    • Y Ylvy
      19 Oct 2022, 04:38

      Is it possible to build the discord widget using any qt widget? or do i need to write a lib for this?

      Discord_2022-10-19_01-36-02.png

      J Offline
      J Offline
      JonB
      wrote on 19 Oct 2022, 07:56 last edited by
      #2

      @Ylvy
      If you mean: can you construct something close to what you show using Qt widgets, then the answer is yes.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 19 Oct 2022, 17:39 last edited by
        #3

        Hi,

        Depending on your goal, you might want to consider QtWebView to show that widget directly.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Y 1 Reply Last reply 19 Oct 2022, 17:49
        0
        • S SGaist
          19 Oct 2022, 17:39

          Hi,

          Depending on your goal, you might want to consider QtWebView to show that widget directly.

          Y Offline
          Y Offline
          Ylvy
          wrote on 19 Oct 2022, 17:49 last edited by Ylvy
          #4

          @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?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 19 Oct 2022, 18:51 last edited by
            #5

            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).

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            Y 2 Replies Last reply 19 Oct 2022, 19:55
            1
            • S SGaist
              19 Oct 2022, 18:51

              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).

              Y Offline
              Y Offline
              Ylvy
              wrote on 19 Oct 2022, 19:55 last edited by Ylvy
              #6

              @SGaist

              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();
              
              }
              
              J 1 Reply Last reply 19 Oct 2022, 21:24
              0
              • Y Ylvy
                19 Oct 2022, 19:55

                @SGaist

                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();
                
                }
                
                J Offline
                J Offline
                JonB
                wrote on 19 Oct 2022, 21:24 last edited by
                #7

                @Ylvy said in Discord widget using Qt:

                QWebEngineView view;

                This is a local/stack variable, it is destroyed at the end of the constructor.

                1 Reply Last reply
                1
                • S SGaist
                  19 Oct 2022, 18:51

                  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).

                  Y Offline
                  Y Offline
                  Ylvy
                  wrote on 20 Oct 2022, 05:36 last edited by
                  #8

                  SGaist 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?

                  1 Reply Last reply
                  0

                  1/8

                  19 Oct 2022, 04:38

                  • Login

                  • Login or register to search.
                  1 out of 8
                  • First post
                    1/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved