[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: [Panel-devel] [PATCH] Layout Code Update
From:       Percy Leonhardt <mailings () eris23 ! de>
Date:       2007-08-16 20:34:50
Message-ID: 200708162234.50132.mailings () eris23 ! de
[Download RAW message or body]

On Thursday 16 August 2007, Aaron J. Seigo wrote:
> there is a small test app in
> kdebase/workspace/libs/plasma/widgets/tests/testLayouts.cpp.

I attached a version that does not work for me. I wanted to have a vertical 
layout containing two rows with horizontal layout each containing 3 widgets.

Where is my misunderstanding of the layouts?

	Percy

["testLayouts.cpp" (text/x-c++src)]

#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>

#include <KUniqueApplication>
#include <KCmdLineArgs>
#include <KCmdLineOptions>
#include <KAboutData>
#include <KIcon>

#include "../pushbutton.h"
#include "../lineedit.h"
#include "../vboxlayout.h"
#include "../hboxlayout.h"
#include "../widget.h"
#include "../label.h"

int main(int argc, char **argv)
{
    KAboutData aboutData( QByteArray("test"), 0, ki18n("test"),
                          KDE_VERSION_STRING, ki18n("test"), KAboutData::License_BSD,
                          ki18n("test") );
    KCmdLineArgs::init(argc, argv, &aboutData);
    KApplication app;

    QGraphicsView view;
    QGraphicsScene scene;
    view.setScene(&scene);

    Plasma::VBoxLayout *widgetLayout = new Plasma::VBoxLayout(0);
    widgetLayout->setGeometry( QRectF(0.0, 0.0, 400.0, 700.0) );

    Plasma::HBoxLayout *h1 = new Plasma::HBoxLayout( 0 );
    Plasma::HBoxLayout *h2 = new Plasma::HBoxLayout( 0 );
    widgetLayout->addItem( h1 );
    widgetLayout->addItem( h2 );

    // should be first row
    Plasma::PushButton *pushOne = new Plasma::PushButton("pushbutton one");
    h1->addItem(pushOne);
    scene.addItem(pushOne);

    Plasma::LineEdit *editOne = new Plasma::LineEdit;
    h1->addItem(editOne);
    scene.addItem(editOne);

    Plasma::Label *labelOne = new Plasma::Label( 0 );
    labelOne->setText( "hello world 1" );
    h1->addItem(labelOne);
    scene.addItem(labelOne);

    // should be second row
    Plasma::PushButton *pushTwo = new Plasma::PushButton("pushbutton two");
    h2->addItem(pushTwo);
    scene.addItem(pushTwo);

    Plasma::LineEdit *editTwo = new Plasma::LineEdit;
    h2->addItem(editTwo);
    scene.addItem(editTwo);

    Plasma::Label *labelTwo = new Plasma::Label( 0 );
    labelTwo->setText( "hello world 2" );
    h2->addItem(labelTwo);
    scene.addItem(labelTwo);

    view.show();
    return app.exec();
}



_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic