Exemple #1
0
int main(int argc, char *argv[]) {

    // инициализация окна
    QApplication a(argc, argv);
    QWebEngineView *view = new QWebEngineView();

    // размеры окна
    int WIDTH = 1024;
    int HEIGHT = 520;

    // размеры Desktop
    int screenWidth;
    int screenHeight;

    // centered
    int x, y;

    // расчет значений Desktop
    QDesktopWidget *desktop = QApplication::desktop();
    screenWidth = desktop->width();
    screenHeight = desktop->height();

    // новые значения
    x = (screenWidth - WIDTH) / 2;
    y = (screenHeight - HEIGHT) / 2;

    // центрируем window
    view->resize(WIDTH, HEIGHT);
    view->move(x, y);

    // title window
    view->setWindowTitle("Игра жизнь");

    // отключаем ненужные Qt события
    view->setContextMenuPolicy(Qt::CustomContextMenu);

    // подгружаем визуализацию
    view->load(QUrl("qrc:live.html"));
    view->show();

    return a.exec();
}
Exemple #2
0
void MainWindow::openPDFWindow(QString url){
    QWebEngineView * pdfView;
    if(!pdfViewList.contains(url)){
        pdfView = new QWebEngineView(0);
        QUrl theurl = QUrl(url);
        pdfView->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

        pdfView->load( theurl );
        pdfView->show();
        pdfViewList.insert(url, pdfView);
        pdfView->setAttribute(Qt::WA_DeleteOnClose);
        pdfView->showNormal();

        int frameHeight = pdfView->frameGeometry().height()-pdfView->geometry().height();
        pdfView->move( (screenRect.width() - 640)/2, screenRect.y() );
        pdfView->resize( 640, screenRect.height()-frameHeight );

        connect(pdfView, SIGNAL(destroyed(QObject*)), this, SLOT(onPDFViewClose(QObject*)) );
        //pdfView->settings()->enablePersistentStorage(QDir::tempPath());
        QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);

    }else{