[Qt-interest] What's the deal with centralWidgets (Qmainwindow) and QLayouts

Efan Harris efanharris at gmail.com
Wed Jan 14 18:26:55 CET 2009


QMainWIndow by default has Layout so when you add a central widget to it, is
is taken care by Mainwindow's layout. You can call layout() function to get
the pointer of this default layout.

Efan

On Wed, Jan 14, 2009 at 9:19 AM, S. Aguinaga <sa_jr at yahoo.com> wrote:

>
> To design a central widget consisting of 3 vhboxlayouts what is the right
> way to set the
> layout?  I have tried using QVBoxes inside of QHBoxes, QGrids, an
> GroupBoxes, and I get the same
> error message when the window opens.  I'm sure I'm missing something
> fundamental.
>
>
> I have widgets (pusbuttons, labels, &c. ) on 3 diff vboxes, then one
> QHBoxLayout that I
> want to add the vboxes, but I keep getting a warning when I run the program
> I get:
>
> "QLayout: Attempting to add QLayout "" to ToneAudWindow "", which already
> has a layout"
>
> and I haven't found a useful answer.
>
> [code]
> ToneWindow::ToneWindow() {
>   createDockingPanels();  //these are fine
>   createCentralWidget();
> }
> void ToneWindow::createCentralWidget() {
>   QGroupBox   *groupBox = new QGroupBox(tr("G1"));
>
>     freqLCD        = new QLCDNumber(5);
>     freqLCD->setSegmentStyle(QLCDNumber::Filled);
>     freqLCD->display( 400 );
>     vbox_c0 = new QVBoxLayout(this); // here I have only one Vertical group
> box
>     vbox_c0->addWidget(new QLabel(tr("Frequency")));
>     vbox_c0->addWidget(freqLCD);
>     groupBox->setLayout(vbox_c0);
>     setCentralWidget(groupBox);
> }
> [/code]
>
> Reference:
> http://lists.trolltech.com/qt-interest/2008-06/thread00514-0.html
>
> Please, any help will be appreciated.
>
> // Sal
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090114/89440619/attachment.html 


More information about the Qt-interest-old mailing list