Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Customize Web Notification in QWebPage
Forum Updated to NodeBB v4.3 + New Features

Customize Web Notification in QWebPage

Scheduled Pinned Locked Moved Qt WebKit
1 Posts 1 Posters 779 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brcontainer
    wrote on last edited by brcontainer
    #1

    I'm creating a simple browser using QtWebkit, I managed to add support for Notification Web API it, as in this example:

    function notifyMe() {
        if (Notification.permission === "granted") {
            var notification = new Notification("Hi there!");
        } else if (Notification.permission !== "denied") {
            Notification.requestPermission(function(permission) {
                if (permission === "granted") {
                    var notification = new Notification("Hi there!");
                }
            });
        }
    }
    
    <button id="nm">Notify me</button>
    
    document.getElementById("nm").onclick = notifyMe;
    

    My code:

    QObject::connect(page,
        SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), this,
        SLOT(featurePermissionRequested(QWebFrame*,QWebPage::Feature))
    );
    
    ...
    
    void Form::featurePermissionRequested(QWebFrame* frame, QWebPage::Feature feature) {
        switch (feature) {
            case 0:
                qDebug() << "Notification";
                page->setFeaturePermission(frame, feature, QWebPage::PermissionGrantedByUser);
            break;
            case 1:
                qDebug() << "GEO";
            break;
        }
    }
    

    Every time I click on the "Notify me" button the following message appears on the desktop:

    Desktop Notification

    It is possible to customize the notifications in QT? In other words, leave similar to the GoogleChrome or Firefox, like this:

    Web Notification

    QT project: https://github.com/brcontainer/qt-helper

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved