2012-12-03 5 views
3

QWebInspector를 QT 프로젝트에 포함 시켰고 코드에서 사용하려고합니다. QW가 아직 완전히 익숙하지 않은 상태에서 어떻게 사용합니까? 빈 웹 검사기 화면이 표시되므로 페이지()가 null을 돌려 주는가? HTML5 애플리케이션에서만 어디서 잘못 되었나요?QWebInspector가 올바르게 작동하지 않습니다.

#include "mainwindow.h" 
#include "ui_mainwindow.h" 
#include <QtGui> 
#include <QSsl> 
#include <QSslError> 
#include <QNetworkReply> 
#include <QtDebug> 
#include <QWebInspector> 
#include <QGraphicsWebView> 
#include <QMessageBox> 
#include "Windows.h" 

MainWindow::MainWindow(QWidget *parent) : 
    QMainWindow(parent), 
    ui(new Ui::MainWindow) 
{ 
    ui->setupUi(this); 
    //this->setGeometry(50,50, 1280, 768); 
    setWindowState(Qt::WindowMaximized); 
    //MainWindow::showMaximized(); 
    this->centralWidget()->setLayout(new QGridLayout); 
    m_pWebView = new QWebView(this); 

    //Detect any SSL errors from the network reply 
    connect(m_pWebView->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> &)), 
        this, SLOT(onSslErrors(QNetworkReply*, const QList<QSslError> &))); 

    this->centralWidget()->layout()->addWidget(m_pWebView); 
    //set position and size 
    m_pWebView->load(QUrl("https://csm.nathan")); 




    //m_pWebView->show(); 

    QMenu *trayIconMenu; 
     minimizeAction = new QAction("Minimize", this); 
     restoreAction = new QAction("Restore", this); 
     quitAction = new QAction("Exit", this); 

     connect (minimizeAction, SIGNAL(triggered()), this, SLOT(hide())); 
     connect (restoreAction, SIGNAL(triggered()),this,SLOT(showMaximized())); 
     connect (quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); 
     trayIconMenu = new QMenu(this); 
     trayIconMenu->addAction (minimizeAction); 
     trayIconMenu->addAction (restoreAction); 
     trayIconMenu->addAction (quitAction); 
     QSystemTrayIcon* systray = new QSystemTrayIcon(this); 
     //connect(systray, SIGNAL(messageClicked()), this, SLOT(messageClicked())); 
     QIcon icon("csm-logo.png"); 
     systray->setIcon(icon); 
     systray->setContextMenu (trayIconMenu); 
     systray->show(); 
     if(systray->isVisible()){ 
      systray->showMessage("CytoViewer v1.0", "The CytoViewer has been started!", QSystemTrayIcon::NoIcon, 10000); 

      //QMessageBox msgBox; 
      //msgBox.setWindowTitle("HELP"); 
      //msgBox.setInformativeText(m_pWebView->page()); 
      //msgBox.exec(); 

      //Enable developer extras in the webviewer settings 
      m_pWebView->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); 
      //Instantiate QWebInspector 
      QWebInspector inspector; 

      inspector.setPage(m_pWebView->page()); 

      inspector.setVisible(false); 
     } 

} 

void MainWindow::onSslErrors(QNetworkReply* reply, const QList<QSslError> &errors) 
{ 
    qDebug() << "handleSslErrors: "; 
    foreach (QSslError e, errors) 
    { 
     qDebug() << "ssl error: " << e; 
    } 
    //Suppress any SSL errors 
    reply->ignoreSslErrors(); 
} 

MainWindow::~MainWindow() 
{ 
    delete ui; 
} 


void MainWindow::closeEvent(QCloseEvent *event) 
{ 
     QMessageBox::information(this, tr("Systray"), 
           tr("The program will keep running in the " 
            "system tray. To terminate the program, " 
            "choose <b>Exit</b> in the context menu " 
            "of the system tray entry.")); 
     hide(); 
     event->ignore(); 
} 

void MainWindow::messageClicked() 
{ 
    QMessageBox::information(0, "CytoViewer Message", "You're application is up and running!"); 
} 

Web Inspector shows blank screen

답변

3

변경

QWebInspector *inspector = new QWebInspector(); 
inspector->show(); 

및 호출이

을 삭제 잊지 마세요
관련 문제