<?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[QGridLayout, help...]]></title><description><![CDATA[<p dir="auto">The following is a demo produced by my engine:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/7c783217-10d4-4a77-97fc-804f938f04db.png" alt="Screenshot 2021-12-01 at 20.29.17.png" class=" img-fluid img-markdown" /><br />
The XML for this:</p>
<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;form title="Test form" id="frmTest" hspacing="0" vspacing="0" width="420"
	  height="360" modal="false"&gt;
	&lt;entry control="listwidget" label="Select" id="enSEL"
		   cols="24" rows="1" mode="single" excludeFromChangeCheck="true"
		   resetPropertiesOnChange="true" eol="true"&gt;
		&lt;subscriber signal="itemSelectionChanged" 
					target="simon2.js@listWidgetHandler"/&gt;		
		&lt;subscriber signal="currentItemChanged"
					target="simon2.js@listWidgetChanged"/&gt;		
	&lt;/entry&gt;
	&lt;entry control="lineedit" label="First name" id="enFN" eol="true"
		   cols="24" maxlength="24" accept="alpha_only" dbfield="vcFirstName"/&gt;
	&lt;entry control="lineedit" label="Surname" id="enSN" eol="true"
		   cols="24" maxlength="24" accept="alpha_only" dbfield="vcSurName"/&gt;
	&lt;label text="Sex"/&gt;		   
	&lt;layout id="rdoLO" height="56" hspacing="0" scrollbar="false" 
			eol="true" type="grid"
 			vspacing="0" properties="QLayout {background-color:#ffaaaa;}"&gt;
		&lt;buttongroup id="enSEX"&gt;
			&lt;radiobutton id="rdoM" height="28" text="Male" default="true"/&gt;
			&lt;radiobutton id="rdoF" height="28" text="Female"/&gt;
		&lt;/buttongroup&gt;
	&lt;/layout&gt;
	&lt;entry control="textedit" label="Address" id="enADR" eol="true"
		   maxlength="256" accept="alpha_numeric" cols="24" rows="5"
		   dbfield="vcAddress"/&gt;
	&lt;entry control="checkbox" label="Employed" id="enEmp" eol="true"
		   dbfield="intEmployed"/&gt;
	&lt;layout id="btnbarLO"  scrollbar="false" type="horizontal" colspan="2"&gt;
		&lt;buttongroup id="enBar"&gt;
			&lt;button id="btnApply" api="applyChanges"&gt;
				&lt;subscriber signal="clicked" target="simon2.js@applyButton"/&gt;
			&lt;/button&gt;
			&lt;button id="btnUndo" api="undoChanges"/&gt;
			&lt;button id="btnOK" api="submitAndClose"/&gt;	
		&lt;/buttongroup&gt;
	&lt;/layout&gt;
	&lt;on saveChanges="Save changes before changing selection?"/&gt;
	&lt;on setup="simon2.js@setupForm"/&gt;
&lt;/form&gt;
</code></pre>
<p dir="auto">Its still very much a work in progress, the code that takes the XML and turns it into a layout:</p>
<pre><code>void clsScriptHelper::addNodesToGUI(clsXMLnode* pobjParent
                                   ,QLayout* pobjLO
                                   ,QJsonArray&amp; raryCells
                                   ,int* pintRow, int* pintCol) {
    static const char scszLabelProperties[] =
                            "QLabel { text-align:left;"
                            "vertical-align: text-top;"
                            "border:0px;"
                            "color:#000000;"
                            "format:rich;"
                            "text-decoration:none; }";
    static int sintNextID(0);
    if ( pobjParent == nullptr || pobjLO == nullptr ) {
        return;
    }
    Qt::Alignment alignment(Qt::AlignLeft | Qt::AlignTop);
    QString strEquals(clsXMLnode::msccEquals);
    clsXMLnode* pobjNode(nullptr);
    int intCol, intRow;
    intCol = (pintCol != nullptr) ? *pintCol : -1;
    intRow = (pintRow != nullptr) ? *pintRow : 0;
    for( QJsonArray::iterator itCell=raryCells.begin()
                            ; itCell!=raryCells.end()
                            ; itCell++ ) {
        QJsonObject objCell(itCell-&gt;toObject());
        QStringList slstAttribs, slstLabel;
        QJsonArray arySubCells;
        int intNodes;
        if ( clsScriptHelper::blnProcessJSON(objCell, slstAttribs, arySubCells) == false ) {
    //Something went wrong!
            continue;
        }
    //Is there a label?
        QString strLabel(clsScriptHelper::strGetAttributeFromList(slstAttribs
                                                                 ,clsXMLnode::mscszAttrLabel));
        if ( strLabel.isEmpty() != true ) {
            intNodes = 2;
            slstLabel &lt;&lt; clsCNT::mscszLabel
                      &lt;&lt; (clsXMLnode::mscszAttrID
                        + strEquals
                        + QString("lbl%1gnrtd").arg(++sintNextID))
                      &lt;&lt; (clsXMLnode::mscszAttrText
                        + strEquals
                        + strLabel)
                      &lt;&lt; (clsXMLnode::mscszAttrProperties
                        + strEquals
                        + scszLabelProperties);
        } else {
            intNodes = 1;
        }
        for( int intNode=1; intNode&lt;=intNodes; intNode++ ) {
    //Create node
            QJsonArray* paryCells(nullptr), aryEmpty;
            QStringList* pslstAttrs(nullptr);
            QString strControl, strGroup;
            if ( intNode == 1 &amp;&amp; slstLabel.isEmpty() != true ) {
                pslstAttrs = &amp;slstLabel;
                paryCells = &amp;aryEmpty;
            } else {
                pslstAttrs = &amp;slstAttribs;
                paryCells = &amp;arySubCells;
    //Get control type from cell
                strControl = clsScriptHelper::strGetAttributeFromList(*pslstAttrs, clsXMLnode::mscszAttrControl);
                if ( strControl.isEmpty() != true ) {
                    QString strFirst(pslstAttrs-&gt;first());
                    if ( strFirst.indexOf(strEquals) == -1 ) {
    //Discard first attribute
                        pslstAttrs-&gt;takeFirst();
    //Replace with control type
                        pslstAttrs-&gt;insert(0, strControl);
                    }
                }
            }
            if ( pslstAttrs == nullptr ) {
                break;
            }
            pobjNode = new clsXMLnode(*pslstAttrs, pobjParent);
            if ( pobjNode == nullptr || pobjNode-&gt;blnCanBeVisible() != true ) {
                continue;
            }
            QWidget* pobjWidget(pobjNode-&gt;pobjGetWidget());
            if ( pobjWidget != nullptr ) {
                const QString cstrName(pobjNode-&gt;cstrGetNodeName());
                clsQtLayout* pobjLayout(nullptr);
                bool blnAdd(true);
                if ( cstrName.compare(clsCNT::mscszLayout) == 0 ) {
                    pobjLayout = static_cast&lt;clsQtLayout*&gt;(pobjWidget);
                    pobjWidget = pobjLayout-&gt;pobjGetScroller();
                } else if ( pobjParent != nullptr ) {
                    clsXMLnode* pobjGrandParent(pobjParent-&gt;pobjGetParent());
                    if ( pobjGrandParent != nullptr ) {
                        const QString cstrGPname(pobjGrandParent-&gt;cstrGetNodeName());
                        if ( cstrGPname.compare(clsCNT::mscszLayout) == 0 ) {
    //The grandparent of this node is a layout, is the parent of this node a layout?
                            const QString cstrPname(pobjParent-&gt;cstrGetNodeName());
                            if ( cstrPname.compare(clsCNT::mscszLayout) != 0 ) {
                                pobjLayout = static_cast&lt;clsQtLayout*&gt;(
                                                pobjGrandParent-&gt;pobjGetWidget());
                                pobjLayout-&gt;addWidget(pobjWidget);
                                blnAdd = false;
                            }
                        }
                    }
                }
                if ( blnAdd == true ) {
                    QGridLayout* pobjGridLO(nullptr);
                    if ( pobjLayout == nullptr ) {
                        pobjGridLO = qobject_cast&lt;QGridLayout*&gt;(pobjLO);
                    }
                    intCol++;
                    if ( pobjGridLO != nullptr ) {
                        pobjGridLO-&gt;addWidget(pobjWidget, intRow, intCol, alignment);
                    } else {
                        pobjGridLO = qobject_cast&lt;QGridLayout*&gt;(pobjLO);
                        if ( pobjGridLO != nullptr ) {
                            QString strColSpan(pobjNode-&gt;strGetAttribute(clsXMLnode::mscszAttrColSpan));
                            int intColSpan(strColSpan.toInt());
                            if ( intColSpan == 0 ) {
                                intColSpan = 1;
                            }
                            pobjGridLO-&gt;addWidget(pobjWidget, intRow, intCol, 1, intColSpan);
                        } else {
                            pobjLO-&gt;addWidget(pobjWidget);
                        }
                    }
                    QString strEOL(pobjNode-&gt;strGetAttribute(clsXMLnode::mscszAttrEndOfLine));
                    if ( strEOL.compare(clsXMLnode::mscszTrue) == 0 ) {
                        intRow++;
                        intCol = -1;
                    }
                }
            }
        }
        if ( arySubCells.size() &gt; 0 ) {
            clsScriptHelper::addNodesToGUI(pobjNode, pobjLO, arySubCells, &amp;intRow, &amp;intCol);
        }
    }
}
</code></pre>
<p dir="auto">The question is why does the checkbox overlap the row above ?</p>
]]></description><link>https://forum.qt.io/topic/132452/qgridlayout-help</link><generator>RSS for Node</generator><lastBuildDate>Wed, 30 Sep 2026 12:12:08 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/132452.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 01 Dec 2021 20:33:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QGridLayout, help... on Wed, 01 Dec 2021 20:46:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/splatten">@<bdi>SPlatten</bdi></a> , fixed:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/7fbbaefa-22c6-49f5-b484-f8ff77e6e78f.png" alt="Screenshot 2021-12-01 at 20.45.56.png" class=" img-fluid img-markdown" /><br />
XML:</p>
<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;form title="Test form" id="frmTest" hspacing="0" vspacing="0" width="420"
	  height="360" modal="false"&gt;
	&lt;entry control="listwidget" label="Select" id="enSEL"
		   cols="24" rows="1" mode="single" excludeFromChangeCheck="true"
		   resetPropertiesOnChange="true" eol="true"&gt;
		&lt;subscriber signal="itemSelectionChanged" 
					target="simon2.js@listWidgetHandler"/&gt;		
		&lt;subscriber signal="currentItemChanged"
					target="simon2.js@listWidgetChanged"/&gt;		
	&lt;/entry&gt;
	&lt;entry control="lineedit" label="First name" id="enFN" eol="true"
		   cols="24" maxlength="24" accept="alpha_only" dbfield="vcFirstName"/&gt;
	&lt;entry control="lineedit" label="Surname" id="enSN" eol="true"
		   cols="24" maxlength="24" accept="alpha_only" dbfield="vcSurName"/&gt;
	&lt;label text="Sex"/&gt;		   
	&lt;layout eol="true" height="56" hspacing="0" id="rdoLO" scrollbar="false" 
			type="grid" vspacing="0" width="72"&gt;
		&lt;buttongroup id="enSEX"&gt;
			&lt;radiobutton id="rdoM" height="28" text="Male" default="true"/&gt;
			&lt;radiobutton id="rdoF" height="28" text="Female"/&gt;
		&lt;/buttongroup&gt;
	&lt;/layout&gt;
	&lt;entry control="textedit" label="Address" id="enADR" eol="true"
		   maxlength="256" accept="alpha_numeric" cols="24" rows="5"
		   dbfield="vcAddress" properties="margin-bottom:16px;"/&gt;
	&lt;entry control="checkbox" dbfield="intEmployed" eol="true" id="enEmp"
		   label="Employed"/&gt;
	&lt;layout colspan="2" id="btnbarLO" scrollbar="false" type="horizontal"&gt;
		&lt;buttongroup id="enBar"&gt;
			&lt;button id="btnApply" api="applyChanges"&gt;
				&lt;subscriber signal="clicked" target="simon2.js@applyButton"/&gt;
			&lt;/button&gt;
			&lt;button id="btnUndo" api="undoChanges"/&gt;
			&lt;button id="btnOK" api="submitAndClose"/&gt;	
		&lt;/buttongroup&gt;
	&lt;/layout&gt;
	&lt;on saveChanges="Save changes before changing selection?"/&gt;
	&lt;on setup="simon2.js@setupForm"/&gt;
&lt;/form&gt;
</code></pre>
]]></description><link>https://forum.qt.io/post/692754</link><guid isPermaLink="true">https://forum.qt.io/post/692754</guid><dc:creator><![CDATA[SPlatten]]></dc:creator><pubDate>Wed, 01 Dec 2021 20:46:38 GMT</pubDate></item></channel></rss>