Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Qt 5.4 WebEngine #120

Open
wants to merge 2 commits into
base: v1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions examples/webengine/webengine.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"fmt"
"os"

"gopkg.in/qml.v1"
"gopkg.in/qml.v1/webengine"
)

func main() {
fmt.Println(qml.Run(func() error {
webengine.Initialize()

engine := qml.NewEngine()
engine.On("quit", func() { os.Exit(0) })

component, err := engine.LoadFile("webengine.qml")
if err != nil {
return err
}
win := component.CreateWindow(nil)
win.Show()
win.Wait()
return nil
}))
}
14 changes: 14 additions & 0 deletions examples/webengine/webengine.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import QtQuick 2.1
import QtWebEngine 1.0
import QtQuick.Controls 1.0

ApplicationWindow {
id: root
width: 1024
height: 768

WebEngineView {
anchors.fill: parent
url: "http://codingame.com"
}
}
6 changes: 6 additions & 0 deletions webengine/webengine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <QtWebEngine>
#include "webengine.h"

void webengineInitialize() {
QtWebEngine::initialize();
}
20 changes: 20 additions & 0 deletions webengine/webengine.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package webengine

// #cgo CPPFLAGS: -I./
// #cgo CXXFLAGS: -std=c++0x -pedantic-errors -Wall -fno-strict-aliasing
// #cgo LDFLAGS: -lstdc++
// #cgo pkg-config: Qt5WebEngine
//
// #include "webengine.h"
import "C"

import (
"gopkg.in/qml.v1"
)

// Initializes the WebEngine extension.
func Initialize() {
qml.RunMain(func() {
C.webengineInitialize()
})
}
14 changes: 14 additions & 0 deletions webengine/webengine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef WEBENGINE_H
#define WEBENGINE_H

#ifdef __cplusplus
extern "C" {
#endif

void webengineInitialize();

#ifdef __cplusplus
} // extern "C"
#endif

#endif // WEBENGINE_H