Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

93
Visualizações
register qscriptengine in qwebchannel

I want to run a permanent JavaScript code that interacts with QWebEngineView in qt. In the code, we have registered the WebClass in the channel. But I'm looking for a way to register a permanent JavaScript code in the channel. and interact QWebEngineView html/javascript code with permanent JavaScript code.

is there any way for that?

    class WebClass : public QObject
    {
        Q_OBJECT
        Q_PROPERTY(QString someattribute MEMBER m_someattribute)
    public slots:
        void jscallme()
        {
            QMessageBox::information(NULL,"jscallme","I'm called by js!");
        }
        void setsomeattribute(QString attr)
        {
            m_someattribute=attr;
           emit someattributeChanged(m_someattribute);
        }
    signals:
        void someattributeChanged(QString & attr);
    private:
        QString m_someattribute;
    };
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setOrganizationName("MNC");
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        QApplication app(argc, argv);
    
        QWebEngineView view;
        auto *channel = new QWebChannel(&view);
        WebClass webClass ;
        channel->registerObject("webclass", webClass);
        view.page()->setWebChannel(channel);
        
        view.setUrl(QUrl(QStringLiteral("http://127.0.0.1:8000")));
    
        view.resize(1024, 750);
        view.show();
    
        return app.exec();
    }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda