Results 1 to 8 of 8

Thread: How to add Treewidget Items when clicking on PushButton

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to add Treewidget Items when clicking on PushButton

    Please also post the corresponding header file. And for a simple debug, try following in your code and show us the output:
    Qt Code:
    1. void newproject::on_okButton_clicked()
    2. {
    3. qWarning() << "on_okButton_clicked";
    4. if(!eclogic)
    5. qWarning() << "no pointer!";
    6. eclogic->createMainTree();
    7. }
    8. //---
    9. void ECLogic::createMainTree()
    10. {
    11. qWarning() << "createMainTree";
    12. QTreeWidgetItem *lnx = new QTreeWidgetItem(ui->treeWidget);
    13. lnx->setText(0,tr("LOGIC"));
    14. ui->treeWidget->addTopLevelItem(lnx);
    15. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2009
    Posts
    35
    Thanks
    12
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11

    Default Re: How to add Treewidget Items when clicking on PushButton

    Quote Originally Posted by Lykurg View Post
    Please also post the corresponding header file. And for a simple debug, try following in your code and show us the output:
    Qt Code:
    1. void newproject::on_okButton_clicked()
    2. {
    3. qWarning() << "on_okButton_clicked";
    4. if(!eclogic)
    5. qWarning() << "no pointer!";
    6. eclogic->createMainTree();
    7. }
    8. //---
    9. void ECLogic::createMainTree()
    10. {
    11. qWarning() << "createMainTree";
    12. QTreeWidgetItem *lnx = new QTreeWidgetItem(ui->treeWidget);
    13. lnx->setText(0,tr("LOGIC"));
    14. ui->treeWidget->addTopLevelItem(lnx);
    15. }
    16.  
    17. Hi,
    18.  
    19. //below is the newproject.h file
    20. [CODE]class newproject : public QDialog
    21. {
    22. Q_OBJECT
    23. public:
    24. Ui::NewProject ui;
    25. newproject(QWidget *parent = 0);
    26. ~newproject();
    27. ECLogic *eclogic;
    28.  
    29. private:
    30.  
    31. newproject *NewPrjct;
    32.  
    33. public slots:
    34. void on_cancelButton_clicked();
    35. void on_okButton_clicked();
    To copy to clipboard, switch view to plain text mode 
    [/CODE]
    //below is the ECLogic.h
    Qt Code:
    1. #include "newproject.h"
    2.  
    3. #include <QApplication>
    4. #include <QtGui/QMainWindow>
    5. #include <QtGui/QDialog>
    6.  
    7. #include <QAbstractButton>
    8. #include <QModelIndex>
    9.  
    10. class ECLogic;
    11. class NewProject;
    12.  
    13. /*************************
    14.  main window(eclogic) Ui name
    15.  *************************/
    16. namespace Ui
    17. {
    18. class ECLogicClass;
    19. }
    20.  
    21. class ECLogic : public QMainWindow
    22. {
    23. Q_OBJECT
    24.  
    25. public:
    26. ECLogic(QWidget *parent = 0);
    27. ~ECLogic();
    28. ECLogic *eclogic;
    29. void createTreewidget();
    30. void create4Bins();
    31. void createMainTree();
    32.  
    33. /*************************
    34.   main window(eclogic) actions slots
    35.   *************************/
    36. private slots:
    37. //when i click on new menu,NewProject window will open.
    38. void on_action_New_triggered();
    39. void on_actionAdd_PLC_triggered();
    40. private:
    41. /*************************
    42.   main window objects
    43.   *************************/
    44. Ui::ECLogicClass *ui;
    45. newproject *NewProject;
    46. ECLogic *eclogic;
    To copy to clipboard, switch view to plain text mode 

    Out put is still getting closing when i click on (Ok)pushbutton
    Qt Code:
    1. Starting /home/th/Desktop/E.0.1/bin/EL...
    2. on_okButton_clicked
    3. no pointer!
    4. createMainTree
    5.  
    6. The program has unexpectedly finished.
    7.  
    8. /home/sumith/Desktop/ECIL-2.0.1/bin/ECIL exited with code 0
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to add Treewidget Items when clicking on PushButton

    The code could not be real! The message "no pointer!" indicates that you don't have initialized eclogic! Add to your constructor
    Qt Code:
    1. eclogic = new ECLogic;
    To copy to clipboard, switch view to plain text mode 
    And therefore I can not understand why "createMainTree" is printed out. So maybe just upload a sample project, that reproduce your problem.

  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to add Treewidget Items when clicking on PushButton

    And therefore I can not understand why "createMainTree" is printed out.
    I don't understand why this guy is trying to write an application if he does not know any programming language... He has two eclogic class members: 1 public and 1 private...
    So maybe just upload a sample project, that reproduce your problem.
    This won't help. I tried to understand the code of his project earlier when there was another topic, but it is impossible as this guy has incredible coding style: almost every line starts with different numbers of spaces from the left... he is using global, local and member variables with the same name which he expect to be the same one variable and so on. He has no idea about C++ programming and can't understand that using umbrella doesn't make sense if you don't know how to open it in rainy day!
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. The following user says thank you to faldzip for this useful post:

    mkkguru (11th February 2010)

  6. #5
    Join Date
    Oct 2009
    Posts
    35
    Thanks
    12
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11

    Default Re: How to add Treewidget Items when clicking on PushButton

    Quote Originally Posted by faldżip View Post
    I don't understand why this guy is trying to write an application if he does not know any programming language... He has two eclogic class members: 1 public and 1 private...

    This won't help. I tried to understand the code of his project earlier when there was another topic, but it is impossible as this guy has incredible coding style: almost every line starts with different numbers of spaces from the left... he is using global, local and member variables with the same name which he expect to be the same one variable and so on. He has no idea about C++ programming and can't understand that using umbrella doesn't make sense if you don't know how to open it in rainy day!
    Hi faldzip,

    Thanks for the answering ,As iam a fresher iam in learning stage ,if you know about my issue plz help regrding this,and dont underestimate others..if i confuse you with my code l will post my project ,

    thanks & regards,

Similar Threads

  1. Replies: 8
    Last Post: 1st October 2015, 07:23
  2. Double Clicking Pro File
    By BalaQT in forum Installation and Deployment
    Replies: 2
    Last Post: 18th November 2009, 05:23
  3. Replies: 1
    Last Post: 28th July 2009, 06:58
  4. Problem editing TreeWidget items
    By Moezzie in forum Qt Programming
    Replies: 3
    Last Post: 15th December 2007, 21:22
  5. Replies: 2
    Last Post: 14th November 2006, 11:22

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
  •  
Qt is a trademark of The Qt Company.