Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to add an widget into the Form In QtDesigner
    text
    copied!<p>in qdesigner_workbench.cpp, how can I add a widget (say QLabel) into a FormWindow by code? Since methods like createWidget()...etc are all abstract, how do I properly use the internal mechanics to add QLabel into the active FormWindow?</p> <p>EDIT:</p> <p>In qdesigner_workbench.cpp, this is currently what I have:</p> <pre><code>QDesignerFormWindowManagerInterface* fwm = core()-&gt;formWindowManager(); QDesignerFormWindowInterface* fw = fwm-&gt;activeFormWindow(); QWidget* mw = fw-&gt;mainContainer(); QLabel* label = new QLabel(mw); //can be added correctly but not in the right hierarchy label-&gt;setText("I am a good girl."); </code></pre> <p>The mw (obtained from fw->mainContainer()) is actually a MainWindow, however the real data I need is in:</p> <pre><code>mw -&gt; children[2] (which is a QDesignerWidget) -&gt; children </code></pre> <p>There are 9 widgets in the designer, and you can see there's 9 arrays in children mentioned above; see this link (an image) for illustration.</p> <p><a href="http://img24.imagevenue.com/img.php?image=98871_a_122_476lo.jpg" rel="nofollow noreferrer">http://img24.imagevenue.com/img.php?image=98871_a_122_476lo.jpg</a></p> <p>So... how can I correctly add the QLabel widget? Tried both</p> <pre><code>QLabel* label = new QLabel(fw); // will be a sibling of MainContainer, which is the QMainWindow (mw) in this case QLabel* label = new QLabel(mw); // will be a sibling of QDesignerWidget </code></pre> <p>and apprarently either of the works.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload