×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    25

    how to create and destroy a widget in qt symbian?

    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
    Join Date
    Nov 2009
    Posts
    25

    Re: how to create and destroy a widget in qt symbian?

    Can anyone help me ?

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    166

    Re: how to create and destroy a widget in qt symbian?

    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
    Join Date
    Nov 2009
    Posts
    25

    Re: how to create and destroy a widget in qt symbian?

    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. 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
    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
  •  
×