Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved QApplication::exec: Must be called from the main thread

    General and Desktop
    3
    3
    806
    Loading More Posts
    • 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.
    • hndery
      hndery last edited by

      Hi again,
      i've got a question again again,,i know this is really unnecessary question.
      But u know.. "question = new question" :D
      i've got one lineEdit for entry url,one button for load and one webView for showing youtube videos.for videos i used youtube embed videos url. for simple explane;

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      #include <QNetworkProxyFactory>
      #include <QRegExp>
      
      
      MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
      	ui->setupUi(this);
      	QNetworkProxyFactory::setUseSystemConfiguration (true);
      	QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
      	QWebSettings::globalSettings()->setAttribute(QWebSettings::AutoLoadImages, true);
      }
      
      
      MainWindow::~MainWindow() {
      	delete ui;
      }
      
      
      void MainWindow::on_loadButton_clicked() {
      	QRegExp exp("youtu(?:\\.be|be\\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)");
      	exp.indexIn(ui->textURL->text());
      	if( exp.capturedTexts().length() >= 2 ) {
      		QString video_url = "http://www.youtube.com/embed/";
      		video_url += exp.capturedTexts().at(1);
      		ui->webView->load( QUrl( video_url ));
      	}
      }
      //https://www.youtube.com/watch?v=LsKFsF2zpFM
      //https://youtu.be/LsKFsF2zpFM
      

      trying to "https://www.youtube.com/watch?v=EIoBvWTzkTY&t=4s"
      and this work very well

      1.png

      except live broadcast videos

      when i try to open live broadcast ;
      "https://www.youtube.com/watch?v=21X5lGlDOfg" <<live link

      2.png

      Application Output:
      QApplication::exec: Must be called from the main thread

      why and how i fix that

      thanks your patience for my silly questions.have good day for all.

      kshegunov 1 Reply Last reply Reply Quote 0
      • Christian Ehrlicher
        Christian Ehrlicher Lifetime Qt Champion last edited by

        You showed us a lot of stuff but nothing where you instantiate your QApplication which is what the error is about.

        Qt has to stay free or it will die.

        1 Reply Last reply Reply Quote 4
        • kshegunov
          kshegunov Moderators @hndery last edited by

          To add to @Christian-Ehrlicher, setting QT_FATAL_WARNINGS in the environment can also give you stack trace about the warning, which'd be immensely helpful to track down where and why this happens.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply Reply Quote 4
          • First post
            Last post