Customize Web Notification in QWebPage



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.