use of userStyleSheetLocation in WebView of QML

QML can you define the CSS alternative to the Web format by using a syntax such as

settings.userStyleSheetLocation: "local:///assets/css/theme.css"?

I am not gettting any errors but are not see the changes reflected on the webview so

Got a solution following syntax
settings.userStyleSheetLocation: "css/theme.css.

If local relative path works very well

Tags: BlackBerry Developers

Similar Questions

  • Use a custom in a signal qml class

    I want to use a custom in a signal qml class, but have difficulties of implementation that correctly.

    My class is OutgoingInputs

    I give the floor

    qRegisterMetaType("OutgoingInputs");
    

    Save a pointer to it as a type of meta, which seems to be necessary, but when I also use

    Q_DECLARE_METATYPE(OutgoingInputs*)
    

    in the header file for the class, I get a compilation error.

    I have to save it without a pointer (was the idea here ) or is there another obvious error?

    Is there an example how to do this?

    I can receive the signal if my housing uses no parameters.

    I don't think you need to register as a metatype... a simple registry should do as it is the same as the use of the QML object:

    qmlRegisterType("mynamespace" 1.0, "OutgoingInputs");

    found this on the forums of qt:

    http://Qt-project.org/forums/viewthread/9657

    I hope that helps!

  • Can I use "If", "else" statement in main.qml?

    Hello

    What statement I use within the main.qml?

    is there documentation for things and the statement can be used within the mian.qml (e.g. 'if', 'for', 'while')

    Hello

    Engine QML use a JavaScript interpreter.

    that statement is bug in Qt 4.8, so it is better to avoid it or explicit use of braces {} in the case branches. Other than that, it is simply JavaScript.

    Syntax information QML is located on the Web site of the project-qt:

    http://Qt-project.org/doc/Qt-4.8/qdeclarativeintroduction.html

    I suggest you browse the other articles there as well.

  • Use QML ImageView in C++

    Hello

    I can see how to use one ImageView, or any other QML declared, stated purpose in QML the constructor method that creates the scene using the QML document, and then sets the AbstractPane root. But how to access an ImageView to anywhere else in the same class? I will keep a reference to the root or document QML?

    You can call Application: instance()-> scene() and cast your object type to top level, something like this:

    Page * appPage = (Page *) Application::instance()-> scene();
    Camera * camera = appPage->findChild ("myCamera");
    etc.

    Or let the appPage pointer or other controls in member variables. In this way, the code will be cleaner.

  • WebView: Content is not being updated after changing the URL

    I wrote a code that updates the Blackberry main.qml WebView URL after that some process is running. QT/C++ code that updates WebView URL is given below

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("app",this);
    AbstractPane *root = qml->createRootObject();
    responseWebPage = root->findChild("responseWebPage");
    responseWebPage->setUrl(QUrl(homePath + "/Appname/updatedhtml.html"));
    

    I even tried to signals and SLOTs and yet it did not work

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("app",this);
    AbstractPane *root = qml->createRootObject();
    responseWebPage = root->findChild("responseWebPage");
    responseWebPage->setUrl(QUrl(homePath + "/Appname/updatedhtml.html"));
    bool response = QObject::connect(responseWebPage, SIGNAL(urlChanged(QUrl)), responseWebPage, SLOT(reload()));
    Q_UNUSED(response);
    Q_ASSERT(response);
    

    WebView main.qml article is

    WebView {
       id: responseWebPage
       objectName: "responseWebPage"
       accessibility.name: "responseWebPage"
       url: "local:///assets/initialcontent.html"
       onUrlChanged: {
          console.debug("URL is changed. New URL is " + responseWebPage.url);
       }
    }
    

    I am able to see the URL name updated in the newspapers printed by WebView debug console. I also checked that the file updatedhtml.html exists. (Checked through the system target file browser). Yet once the URL is set, I see no updatedhtml.html content displayed in device or Simulator. Is there any step I'm missing? Any help is greatly appreciated

    Ahh, I see what you're missing today.  You have created a new Page, it adds the WebView and set its URL, but you have actually posted this page.  What kind of navigation you are trying to use here?  If you want to display a new page and allow the user to return to the previous, look here: https://developer.blackberry.com/native/documentation/ui/navigation/multiple_screens_stack.html

    If you want to replace the current page with a new one, you must call setScene.  Alternatively, you can access the page currently displayed when it exists and update the WebView on it.

    Whatever approach you take, I recommend this reading for an overview on how the user of Cascades interface fit: https://developer.blackberry.com/native/documentation/dev/fundamentals/index.html

  • WebView (10.1.0.273, 10.1.0.1435) showed that 3mm in height. 10.0.9/10.0.10 is OK.

    Hello

    I checked my file (stored in the phone) local html in HTML5 OK.

    He showed good, filling the entire screen on v10.0.X z10 and q10.

    However, on 10.1.X e.g. 10.1.0.273, 10.1.0.1435, it is only 3mm in height.

    Appreciate advice.

    * Update: found by webinspector dimension html element width & height to 10.1 is detected as 342 x 7 px while 10.0.X is 342 x 570px. Anyone with an explanation why is it the case? Guess I can fix by defining for example 342px to height to work around.

    * Workaround solution: managed to obtained a solution using CSS media query to adjust height until I have found why 100% is interpreted as "7px" by 10.1 when the full width of 10.0.

    Solution: Use Innovatology suggestion.

    Thank you
    James Tan

    -My CSS for the Web of google map-

    
    

    -My Webview in QML call is very simple-

    WebView {
        id: webView
        url: "local:///assets/webview/index.html"
    }
    

    -Here's a screenshot of the display in 10.1-

    Known issue on 10.1:

    https://www.BlackBerry.com/jira/browse/BBTEN-1247

    Workaround solution, should work on 10.0 too:

    WebView {
        ...
        preferredWidth: Infinity
        preferredHeight: Infinity
    }
    
  • How to get the content of the list item selected ListView using CPP?

    Hello

    I do a simple application, get the content of the list item selected ListView using CPP, in the main.qml file, I created a listview using XMLDataModel and I got the selected listview using dataModel.data (row) .attributeNameInXmlfile in qml. content as in the same way the ListView using cpp.please help me I want to get the content of the listitem selected.

    Here is my code

    hand. QML

    import bb.cascades 1.0
    
    Page {
        content: Container {
            id: mainContainer
            objectName: "container"
            // property alias selectedText: selectedTextField.text
            //property alias deselectedText: deselectedTextField.text
            ListView {
                objectName: "listView"
                dataModel: XmlDataModel {
                    source: "models/items.xml"
                    id: model
                }
                listItemComponents: [
                    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            title: ListItemData.title
                        }
                    }
                ]
            }
            TextField {
                id: selectedTextField
                objectName: "selectedTextField"
                text: ""
            }
            TextField {
                id: deselectedTextField
                objectName: "deselectedTextField"
                text: ""
            }
        }
    }
    

    App.cpp

    #include "app.hpp"
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    using namespace std;
    
    using namespace bb::cascades;
    QObject *textFieldSelected ;
    QObject *textFieldNotSelected;
    QObject *list;
    App::App() {
        QmlDocument *qml = QmlDocument::create("main.qml");
        AbstractPane *root = qml->createRootNode();
        list = root->findChild("listView");
        textFieldNotSelected = root->findChild("deselectedTextField");
        textFieldSelected = root->findChild("selectedTextField");
        QObject::connect(list,SIGNAL(selectionChanged (QVariantList, bool)),this,SLOT(changeText(QVariantList, bool)));
        Application::setScene(root);
    }
    
    void App::changeText(QVariantList indexPath,bool selected) {
    
    }
    

    App.HPP

    #ifndef APP_H
    #define APP_H
    
    #include 
    #include 
    #include 
    
    /*!
     * @brief Application GUI object
     */
    class App : public QObject
    {
        Q_OBJECT
    public:
        App();
    public slots:
    void changeText(QVariantList ,bool );
    
    };
    
    #endif // ifndef APP_H
    

    Try this.

    void App::changeText(QVariantList indexPath,bool selected) {
        XmlDataModel *model = (XmlDataModel *)list->dataModel();
        QVariantMap map = model->data(indexPath).toMap();
        // map is your data in QVariant
        qDebug() << map["title"].toString();
    }
    
  • ImageView or webview

    I want to get an image in a listview. the image is from a url. should I use component imageview or webview.

    who can tell me the difference

    THX

    Just to add to the response of @pyth, since it's on the web, you must use asynchronous loading with...

    A few resources to help you...

    http://developer.BlackBerry.com/native/documentation/Cascades/UI/lists/asynch_data.html

    http://BlackBerry.github.IO/Cascades-samples/ImageLoader.html

  • In any case to have an onLoad function in qml appending NavigationPane?

    I'm new to Blackberry 10 dev. So I was wondering what is the best way to do that I get no clear answer dev documentation.

    What I want is to start a separate view in my application from a navigation screen. The new page will then create an http request and update the UI based on the output.

    The best way seems to use the NavigationPane and add view qml. But how do I invoke a C++ function when placed on the stack? Something similar to android onActivityCreated() in Fragments. There are the docs for example Http, but the program started the HTTP from the legacy of the QObject constructor. How I have a function that is executed as the new qml is added to the navigation as a stack

     // navigationpane.qml
    
    NavigationPane {
        id: navigationPane
        Page {
            Container {
                Label {
                    text: "First page"
                }
            }
    
            actions: [
                ActionItem {
                    title: "Next page"
                    ActionBar.placement: ActionBarPlacement.OnBar
                    onTriggered: {
                        var page = pageDefinition.createObject();
                        navigationPane.push(page);
                    }
    
                    attachedObjects: ComponentDefinition {
                        id: pageDefinition;
                        source: "secondpage.qml"
                    }
                }
            ]
        }
        onPopTransitionEnded: { page.destroy(); }
    }
    

    Most of the QML objects have a creationCompleted signal, so you can set an onCreationCompleted: {...} to do what I think that you ask for.

    Note that it runs only when the thing is first created, well... If you reuse (hide but not destroy it, and the later make visible again) you'll need something else. Some components have relevant signals for this (for example onOpened, I think, for dialogue) but for others, you need make your own signal (which is trivial to do well).

  • To access the properties of QML context through several QML files

    It seems so basic, but I don't see how well...

    I put a 'WebAPI' context property to access my class that makes HTTP requests etc. WebAPI works very well main.qml, but when I try and use it in the included LargeThumbItem.qml I get:

    "LargeThumbItem.qml:37: ReferenceError: can't find variable: WebAPI.

    How to set a context property that is available for * all * my QML files? What is the best practice for this?

    hand. QML

    {

    ...

    {ListItemComponent}

    type: 'point '.

    LargeThumbItem {

    }

    }

    ....

    }

    LargeThumbItem.qml

    {

    ....

    WebAPI.getImagePath (...)

    ...

    }

    I do the usual configuration...

    QmlDocument * qml = QmlDocument::create("asset:///main.qml").parent(this);

    QML-> setContextProperty ("WebAPI", m_pWebAPI);

    I tried calling qml-> documentContext()-> setContextProperty(), but it did not work. Is there a global context that I can put all documents will inherit? (the API documentation seems to suggest there is).

    This problem is related to what is described here and the solution is the same. The problem is that the ListItemComponents have a different context and lifecylce due to the fact that they are cached in and out as the scrolls of the ListView (see here for details).

    I solved it by adding a dynamic property on the global object of 'Qt' for example in onCreationCompleted() or anywhere where the senses in main.qml. In my case, I chose to pass a string, because I don't know if the global property to the instance around WebAPI is a good idea.

    Qt.homeListBaseURL = WebAPI.getImagePath ("TitleImagePathPrefix", "170 x 240")

    Then in LargeThumbItem.qml for example

    {WebImageView}

    ...

    URL: Qt.homeListBaseURL + ListItemData.ContentId + '.jpg '.

    ...

    }

  • A return to the QML container onCreationComplete event Q_String

    Hello

    I'm trying to regain a QString funcition onCreationComplete a container.

    Here is the code I use.  When I debug the QML debugger jumps on the

    event and moves on to the next control.  I'm guessing that there is an error of some sort, but I don't know what it is.

    Thanks in advance.

    file .qml

    onCreationCompleted: {}
    If (ListItemData.channelName is {MSNApp.getSelectedChannel ()})
    Background = Color.create("#74D2F7")
    }
    }

    all files

    public:

    QString Q_INVOKABLE getSelectedChannel();

    private:

    QString selectedChannel;

    .cpp file

    selectedChannel = 'Home';  Download initialized in the constructor

    QString ApplicationUI::getSelectedChannel() {}

    Return selectedChannel;
    }

    Aparently there is a bug when it comes to properties of context and ListView.  I found this work around.

    Thanks for the suggestions.

    http://supportforums.BlackBerry.com/T5/Cascades-development/cannot-access-context-property-from-INSI...

    Best regards

    John

  • ListView: ListItemComponents (QML) vs ListItemProvider/Auditors (C++)

    Hello

    I develop an application that uses a list view, which contains different types of list items (one with a single image, with lots of text and 3 photos, etc...)

    I beguntaking the way of the implement in C++ because it did not seem possible based on QML so much I wanted to. I have my own DataModel inheriting from the ArrayDataModel class, and a form that inherits from ListViewItemFactory ListItemProvider and various ListItemListeners. These ListItemListeners all contain the equivalent of C++ code QML which create a container (containers, updates page, inages, labels, etc...)

    My question is, can I use my own datamodel and support QML for my ListView and his ListItemComponents instead of the ListItemProvider/ListItemListener equivalent in C++? If possible, why a person go about creating these in C++?

    Thank you

    Martin

    You can certainly do it in QML by substituting the itemType in javascript function in your ListView control. I think this is good for simple cases where you're not different, but several types of items when you have a lot of guys, and the code becomes more complex, it becomes a little heavy to do all the javascript. Especially if you are using custom data. Layer c ++ is also slightly more fast. You probably won't notice the difference, but there is a slight speed increase.

  • QML Clipboard

    Hello

    I try to use the bb::system:Clipboard in QML. I get this error:

    TypeError: Result of expression 'clipboard.insert' [undefined] is not a function.

    I found this explanation:

    http://StackOverflow.com/questions/18611349/TypeError-result-of-expression-dbmasterobject-updateinto...

    I looked into:

    C:\bbndk\...\qnx6\usr\include\bb\system\Clipboard.hpp

    and there is no slots and no methods have been marked of Q_INVOKABLE.

    Does this mean that I can't use the Clipboard class in QML? If anyone can confirm this?

    I'll try to write some methods in C++ in my app and try to call these methods from QML.

    ARO

    René

    Exactly what this means, two options

    (1) make your own Q_INVOKABLE function (as you suggested)

    (2) register the class for use in QML

  • WebView does not have Javascript

    Hello

    I am loading a simple web page in Web view. The page runs only a Javascript function that allows the user to browse to files. When I type the address in the BlackBerry browser, everything works fine, but when I try to load the same page in WebView - nothing happens, no Javascript content is presented.

    Any ideas?

    Thank you

    Thank you for your response.

    My problem was that I used setHtml() on my WebView. When I changed my code to work with setUrl() everything works fine

    Thanks, best regards

  • Working with GIF Image

    Hello guys,.

    I want to use a GIF image in a Qml (ImageView) file.

    I've used this, but it did not work. (No animation)

    ImageView {}
    horizontalAlignment: HorizontalAlignment.Fill
    verticalAlignment: VerticalAlignment.Fill
    ID: imageView
    imageSource: "3.gif".
    attachedObjects:]
    ImageAnimator {}
    ID: imageAnimator
    animatedImage: imageView.image
    started: true
    }
    ]
    }

    Thank you

    He worked with a Web view

    WebView

    {

    URL:"local:///assets/image.gif".

    }

Maybe you are looking for