<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Navigation inside a QML page due to external inputs]]></title><description><![CDATA[<p dir="auto">I have several QML pages each one with custom objects that appears as "buttons" or other focusable items.<br />
The target machine has no mouse nor keyboard and the navigation among items is provided by external devices. From them I received via serial or ethernet some events that I forward as signals to the QML pages.</p>
<p dir="auto">So I have signals like "click", "up", "down", "left" and "right".</p>
<p dir="auto">Each custom object has a property that define its state: deselected, selected and clicked.<br />
Whenever I receive such a signal I should update those properties according to the page layout.</p>
<p dir="auto">Let's suppose I have two "buttons" in a column and an icon in the upper-right corner of the page. On startup the focus is set on the first button, then:</p>
<ol>
<li>if I receive "up" go to the icon</li>
<li>if I receive "down" go to the second button</li>
<li>if I receive "click" execute the button function</li>
</ol>
<p dir="auto">then if I moved to the second button:</p>
<ol>
<li>if I receive "up" go to the first button</li>
<li>if I receive "click" execute the button function</li>
</ol>
<p dir="auto">Of course it depends on the page layout and also by the customer's requirements (i.e. when on the second button a "down" would go back to the first button or even to the icon).</p>
<p dir="auto">Defining all these conditions with a straight fsm would require a <strong>huge</strong> quantity of if..else statements.<br />
Is there something smarter to achieve the same?</p>
<p dir="auto">In C/C++ I would define a list of struct bound together using pointers:</p>
<pre><code>typedef struct
{
    QString name;
    item_t *up;
    item_t *down;
    item_t *left;
    item_t *right;
} item_t;

item_t items[ITEMS_NUM];
int currItem;
</code></pre>
<p dir="auto">Whenever I receive an event I look for the current item and if the related pointer is not <code>null</code> I move toward the target item.</p>
<p dir="auto">What do you suggest in QML?</p>
]]></description><link>https://forum.qt.io/topic/91550/navigation-inside-a-qml-page-due-to-external-inputs</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 22:23:04 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/91550.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 11 Jun 2018 12:54:43 GMT</pubDate><ttl>60</ttl></channel></rss>