Important: Please read the Qt Code of Conduct -

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

  • 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) {
    	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-_]+)");
    	if( exp.capturedTexts().length() >= 2 ) {
    		QString video_url = "";
    		video_url += exp.capturedTexts().at(1);
    		ui->webView->load( QUrl( video_url ));

    trying to ""
    and this work very well


    except live broadcast videos

    when i try to open live broadcast ;
    "" <<live link


    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.

  • Lifetime Qt Champion

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

  • Moderators

    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.

Log in to reply