Results 1 to 6 of 6

Thread: New item not saved to combobox when added dynamically

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2014
    Posts
    31
    Thanks
    7
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Post New item not saved to combobox when added dynamically

    Hello all,
    I am new to Qt, i am trying to add a new item to combobox when a pushbutton is clicked. At that time the combobox is showing the added item but when i closed the app and open the app it doesn't showing the added item i.e it is not saved to combobox.

    How to save the new item to combobox

    Here is my code:

    mainwindow.h

    Qt Code:
    1. private slots:
    2. void on_pushButton_clicked();
    3.  
    4. private:
    5. Ui::MainWindow *ui;
    6. QComboBox *comboBox;
    7. QPushButton *pushButton;
    To copy to clipboard, switch view to plain text mode 

    mainwindow.cpp

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. comboBox=ui->comboBox;
    7. pushButton=ui->pushButton;
    8. }
    9.  
    10. void MainWindow::on_pushButton_clicked()
    11. {
    12. comboBox->addItem("hari");
    13. }
    To copy to clipboard, switch view to plain text mode 


    Please help me ASAP!! this is really urgent! thank you very much!!
    Last edited by anda_skoa; 8th March 2014 at 15:23. Reason: changed [qtclass] to [code]

Similar Threads

  1. Replies: 2
    Last Post: 3rd June 2013, 16:45
  2. Replies: 8
    Last Post: 2nd February 2012, 19:52
  3. Replies: 0
    Last Post: 25th July 2011, 14:11
  4. Automatic file extension is not added to saved file on mac os x
    By sanjayshelke in forum Qt Programming
    Replies: 0
    Last Post: 30th October 2009, 06:56
  5. Connecting dynamically added properties
    By stefkeB in forum Qt Programming
    Replies: 1
    Last Post: 5th December 2008, 15:19

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.