Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User ngoanrazor's Avatar
    Join Date
    Nov 2009
    Posts
    25
    hello everybody!
    i want create and destroy awidget in application ( same in dotnet of microsoft)

    example: i have a main widget, it contain 2 button a,b. i want when press button a, it will create another widget (this widget is chill of main widget) and when press button b, it will destroy this widget. please guide me code it

    my problem same at http://www.developer.nokia.com/Commu...-new-one-again
    Last edited by ngoanrazor; 2011-09-19 at 14:25.

  2. #2
    Registered User ngoanrazor's Avatar
    Join Date
    Nov 2009
    Posts
    25
    Can anyone help me ?

  3. #3
    Registered User kunal_the_one's Avatar
    Join Date
    Jul 2004
    Posts
    166
    I tried following code, works fine for me.

    -----------------
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),_widget(0)
    {
    QWidget *widget = new QWidget(this);

    QPushButton* btn1 = new QPushButton("Create",this);
    QPushButton* btn2 = new QPushButton("Destroy",this);

    QVBoxLayout* mainLaout =new QVBoxLayout(widget);
    mainLaout->addWidget(btn1);
    mainLaout->addWidget(btn2);

    connect(btn1,SIGNAL(clicked()),this,SLOT(create()));
    connect(btn2,SIGNAL(clicked()),this,SLOT(destroy()));

    widget->show();
    setCentralWidget(widget);
    }

    void MainWindow::create()
    {
    _widget = new QWidget();

    QPushButton* btn1 = new QPushButton("Hello",this);

    QVBoxLayout* mainLaout =new QVBoxLayout(_widget);
    mainLaout->addWidget(btn1);

    _widget->show();
    }

    void MainWindow::destroy()
    {
    delete _widget;
    _widget = 0;
    }
    http://kunalmaemo.blogspot.com/

  4. #4
    Registered User ngoanrazor's Avatar
    Join Date
    Nov 2009
    Posts
    25
    Quote Originally Posted by kunal_the_one View Post
    I tried following code, works fine for me.

    -----------------
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),_widget(0)
    {
    QWidget *widget = new QWidget(this);

    QPushButton* btn1 = new QPushButton("Create",this);
    QPushButton* btn2 = new QPushButton("Destroy",this);

    QVBoxLayout* mainLaout =new QVBoxLayout(widget);
    mainLaout->addWidget(btn1);
    mainLaout->addWidget(btn2);

    connect(btn1,SIGNAL(clicked()),this,SLOT(create()));
    connect(btn2,SIGNAL(clicked()),this,SLOT(destroy()));

    widget->show();
    setCentralWidget(widget);
    }

    void MainWindow::create()
    {
    _widget = new QWidget();

    QPushButton* btn1 = new QPushButton("Hello",this);

    QVBoxLayout* mainLaout =new QVBoxLayout(_widget);
    mainLaout->addWidget(btn1);

    _widget->show();
    }

    void MainWindow::destroy()
    {
    delete _widget;
    _widget = 0;
    }

    thank you!

Similar Threads

  1. How to create S3 Home Screen Widget?
    By JohnsonZ in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2011-08-03, 02:56
  2. how to create widget that supports in multiple device?
    By kalpesh_sttl in forum Symbian Web Runtime
    Replies: 1
    Last Post: 2010-10-04, 11:00
  3. Replies: 6
    Last Post: 2010-09-29, 16:11
  4. Replies: 1
    Last Post: 2009-12-20, 05:28
  5. create and delete widget shortcut icon
    By priti2208 in forum Symbian Web Runtime
    Replies: 9
    Last Post: 2009-07-31, 11:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved