User Tools

Site Tools


k12:k12.1:start

12.1 Form

In the following three chapters the class Form (gb.qt4) is described in detail with the most important properties, methods and events as well as the constants used.

In chapter 12.2, the descriptions of the properties, the methods or the events are followed by complete projects and example source texts in which the use of the class Form is shown.

In the following example, the RSS feed data in XML format (→ Chapter 18.12.5 RSS reader) of a website are read out and this abbreviated XML source text excerpt results for an entry:

<item>
  <title>DFB-Elf auf EM-Kurs</title>
  <link>http://www.sportschau.de/fussball/nationalmannschaft/...bericht-deutschland...100.html</link>
  <description>The German national football team beat Scotland 3-2 in Glasgow and is now on the brink of qualifying for the
  European Championship. For the Scots ... .</description>
</item>

In the procedure ParseNode(Node As XMLNode), the data for title and description are filtered out of all entries (<item>…</item>) and displayed in a new form (hFeed of type FeedItem). These forms generated at runtime are inserted into a 'ListContainer' in the main programme:

Public Sub ParseNode(Node As XmlNode)
  Dim xmlNode, xmlAttribute As XmlNode
  Dim hFeed As FeedItem
 
  For Each xmlNode In Node.Children
    If xmlNode.Name = "item" Then
       hFeed = New FeedItem(ListContainer.Count + 1, ListContainer)
       For Each xmlAttribute In xmlNode.Children
         Select Case xmlAttribute.Name
           Case "title"
             hFeed.FeedTitle = xmlAttribute.Value
           Case "description"
             hFeed.Description = xmlAttribute.Value
           Case "link"
             hFeed.Link = xmlAttribute.Value
         End Select
       Next ' Each xmlAttribute
    Else
       If xmlNode.Children.Count > 0 Then ParseNode(xmlNode) ' Recursive call!
    Endif ' xmlNode.Name = "item" ?
  Next ' Each xmlNode
 
End ' ParseNode(...)

Using the filtered out link, the corresponding web page is additionally loaded and displayed in a WebView when one clicks on a inserted form in the ListContainer.

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k12/k12.1/start.txt · Last modified: 01.02.2022 (external edit)

Page Tools