×

Discussion Board

Results 1 to 7 of 7

Hybrid View

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    19

    QWebView and special character like @

    Hi!

    I am trying to run a test application that uses QWebView for asking a text entry.
    I am able to type any characters in the text entry on the N900, but special character like "@" (character 2 is appearing instead) just doesn't appears in the Fremantle SDK on my desktop.
    I am using Qt4.6 for Maemo5

    Here is the code
    qwebview.pro:
    Code:
    TEMPLATE = app
    TARGET = qwebview
    DEPENDPATH += .
    INCLUDEPATH += .
    CONFIG += qt debug
    QT += network webkit
    
    HEADERS += qwet.h 
    SOURCES += main.cpp qwet.cpp
    
    RESOURCES += qwebview.qrc
    qwebview.qrc:
    Code:
    <RCC>
        <qresource prefix="/">
            <file>html/view.html</file>
            <file>css/view.css</file>
        </qresource>
    </RCC>
    Code:
    #ifndef QWET_H
    #define QWET_H
     
    #include <QtCore/QPointer>
     
    #include <QtWebKit/QWebView>
    #include <QtWebKit/QWebPage>
    #include <QtWebKit/QWebFrame>
     
    #include <QtGui/QWidget>
    #include <QtGui/QApplication>
    #include <QtGui/QMainWindow>
    #include <QtGui/QFrame>
    #include <QtGui/QVBoxLayout>
     
    class QWET : public QMainWindow
    {
        Q_OBJECT
     
    public:
        QWET(QWidget *parent = 0);
     
    private:
        QPointer<QWebView> _webView;
        QPointer<QVBoxLayout> _layout;
    };
     
    #endif // QWET_H
    qwet.cpp:
    Code:
    #include "qwet.h"
     
    QWET::QWET(QWidget *parent) : QMainWindow(parent) 
    {
        QFrame* cW = new QFrame(this);
        setCentralWidget(cW);
     
        _layout = new QVBoxLayout(this);
        cW->setLayout(_layout);
        _layout->setMargin(0);
        _layout->setSpacing(0);
     
        _webView = new QWebView(this);
        _webView->load(QUrl("qrc:///html/view.html"));
        _webView->show();
     
        _layout->addWidget(_webView);
    }
    css/view.css:
    Code:
    @CHARSET "UTF-8";
     
    html {
        background-color: lightgray;
        margin: 1em 0 0 1em;
        padding: 0;
    }
     
    body {
        margin: 0;
        padding: 0;
    }
     
    h1#header {
        color: black;
        margin: 0;
        padding: 0;
    }
     
    p {
        color: black;
        margin: 0 0 0 5pt;
        padding: 0;
    }
     
    form#form {
        color: black;
        margin: 0 0 0 5pt;
        padding: 0;
    }
     
    fieldset {
        border: 0;
    }

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
      <head>
        <!-- You reference the resources with qrc:// -->
        <!-- Stylesheet reference -->
        <link rel="stylesheet" href="qrc:///css/view.css" />
     
        <title>WebKit example</title>
      </head>
      <body>
        <!-- Header -->
        <h1 id="header">Welcome</h1>
        <!-- Paragraph -->
        <p id="paragraph">Hello World!</p>
        <!-- Form -->
        <form id="form" action="#">
          <fieldset>
            <label for="text">Text</label>
            <!-- Text input -->
            <input id="text" type="text" />
            <!-- Submit button -->
            <input id="button" type="button" value="Submit!"/>
          </fieldset>
        </form>
      </body>
    </html>
    Do I have to set something in my Scratchbox target, the in Hildon desktop, or I have to set some QWebView settings ?


    Thanks

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    19

    Re: QWebView and special character like @

    Ok, I don't think my issue is related to QWebView: I have tried to type "@" in the "Account Setup" dialog of the Maemo Address book and the character doesn't appears.

  3. #3
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QWebView and special character like @

    You issue is not related to Qt. It's actually Xephyr bug. What is version of your Linux distribution, xserver-xephyr you have and what is an exact command you use to start Xephyr?

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    19

    Re: QWebView and special character like @

    I am developing on Ubuntu 9.10 Karmic Koala and xephyr version is 2:1.6.4-2ubuntu4.1
    My xephyr command is : Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb

  5. #5
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QWebView and special character like @

    There is a small test app:
    Code:
    /*  Compile with:
     *  gcc -Wall -g events.c -o events $(pkg-config --cflags --libs gtk+-2.0)
     */
    
    #include <X11/Xlib.h>
    #include <X11/Xatom.h>
    #include <stdlib.h>
    #include <string.h>
    #include <glib.h>
    #include <gdk/gdkx.h>
    #include <gdk/gdkkeysyms.h>
    #include <gdk/gdkx.h>
    #include <gtk/gtk.h>
    
    static void
    set_zoom_atom (GtkWidget *window,
                   gint state)
    {
            GdkWindow      *gdk_window;
            GdkDisplay     *display;
    
            state = state > 0 ? 1 : 0;
    
            gdk_window = window->window;
            if (!gdk_window) {
                    g_print ("Not available window\n");
                    return;
            }
            display = gdk_drawable_get_display ((GdkDrawable*)gdk_window);
            if (!display) {
                    g_print ("Not available display\n");
                    return;
            }
            XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                             GDK_WINDOW_XID (gdk_window),
                             gdk_x11_get_xatom_by_name_for_display
                                            (display, "_HILDON_ZOOM_KEY_ATOM"),
                             XA_INTEGER, 32, PropModeReplace,
                             (unsigned char*) &state, 1);
    }
    
    
    static gboolean
    key_cb (GtkWidget   *widget,
            GdkEventKey *event,
            gpointer     user_data)
    {
            const gchar *msg;
    
            switch (event->type) {
            case GDK_KEY_PRESS:
                    msg = "press";
                    break;
            case GDK_KEY_RELEASE:
                    msg = "release";
                    break;
            default:
                    msg = "unknown";
                    break;
            }
            g_print ("%s\tstate[0x%x]\tkey[0x%x]\n", msg, event->state, event->keyval);
    
            return FALSE;
    }
    
    
    
    static void
    destroy_cb (GtkWidget *widget,
                gpointer   data)
    {
            gtk_main_quit ();
    }
    
    
    gint
    main (gint argc,
          gchar **argv)
    {
            GtkWidget *window;
    
            gtk_init (&argc, &argv);
    
            window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    
            g_signal_connect (G_OBJECT (window), "delete-event",
                              G_CALLBACK (destroy_cb), NULL);
            g_signal_connect (G_OBJECT (window), "key-press-event",
                              G_CALLBACK (key_cb), NULL);
            g_signal_connect (G_OBJECT (window), "key-release-event",
                              G_CALLBACK (key_cb), NULL);
    
            gtk_widget_show_now (window);
            gdk_window_set_events (window->window,
                                   GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
    
            set_zoom_atom (window, 1);
    
            gtk_main ();
    
            exit (0);
    }
    You can see that AltGr modifier (I use Swedish keyboard) is not taken into account in scratchbox. I guess the issue with key maps inside X86 scratchbox target.

  6. #6
    Registered User
    Join Date
    Jan 2010
    Posts
    19

    Re: QWebView and special character like @

    Ok, thanks, I've filled a bug to Maemo SDK
    https://bugs.maemo.org/show_bug.cgi?id=9364

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×