Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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) {
    	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.


  • 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