Skip to content

Instantly share code, notes, and snippets.

@tru
Created October 7, 2014 09:12
Show Gist options
  • Select an option

  • Save tru/b05660191544801c01a8 to your computer and use it in GitHub Desktop.

Select an option

Save tru/b05660191544801c01a8 to your computer and use it in GitHub Desktop.
#include "mainwindow.h"
#include <QWebEngineView>
#include <QGLWidget>
#include <QStackedWidget>
#include <QShortcut>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setMinimumSize(1280, 720);
m_web = new QWebEngineView(this);
m_web->setUrl(QUrl("http://www.google.com"));
m_web->setAccessibleName("web");
setCentralWidget(m_web);
m_glWidget = new QGLWidget(this);
m_glWidget->setAttribute(Qt::WA_NativeWindow);
QShortcut* shortcut = new QShortcut(QKeySequence("Ctrl+R"), this);
connect(shortcut, SIGNAL(activated()), this, SLOT(switchView()));
}
void MainWindow::switchView()
{
if (centralWidget()->accessibleName() == "web")
setCentralWidget(m_glWidget);
else
setCentralWidget(m_web);
}
MainWindow::~MainWindow()
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment