Page 3 of 3 FirstFirst 123
Results 41 to 42 of 42

Thread: QTreeWidget clicked signal

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

    Default Re: QTreeWidget clicked signal

    Quote Originally Posted by faldżip View Post
    I mean C++ type... To make you things easier I can say that in this code:
    Qt Code:
    1. void ECLogic::showItem(QTreeWidgetItem* item )
    2. {
    3. if(item=="PLC")
    4. {
    5. PLCconfig=new plcconfiguration();
    6. main_tab_widget->insertTab(0,PLCconfig, "PLC");
    7. main_tab_widget->setCurrentIndex(0);
    8. PLCconfig->show();
    9. }
    10. else if(item==lnx)
    11. {
    12. ECLogic_Lnx=new eclogic_lnx(main_tab_widget);
    13. ECLogic_Lnx->setWindowTitle(QString("ECLOGIC-LNX"));
    14. ECLogic_Lnx->show();
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 
    item's type is QTreeWidgetItem* and "PLC" is const char *, so both are pointers. Do you want to compare two memory addresses of two completely different things? I don't think so...
    And again:

    You have created them in another method as local variables so they not exist where you want to reference them. They are dead :]

    Your problem now is pure C++ issue. Please revise your C++ basics, like local variables, scopes, referencing pointers and so on.

    And your project your slot showItem looks:
    Qt Code:
    1. void ECLogic::showItem(QTreeWidgetItem* item )
    2. {
    3.  
    4. ECLogic_Lnx=new eclogic_lnx(main_tab_widget);
    5. ECLogic_Lnx->setWindowTitle(QString("ECLOGIC-LNX"));
    6. ECLogic_Lnx->show();
    7.  
    8. item << "PLC" << "CPU CONFIGURATION" << "PROGRAM VARIABLE CONFIGURATION" << "IO CONFIGURATION"
    9. << "BIN" << "SLOT" <<"LADDER PROGRAM";
    10.  
    11. if(item=="PLC")
    12. {
    13. PLCconfig=new plcconfiguration();
    14. main_tab_widget->insertTab(0,PLCconfig, "PLC");
    15. main_tab_widget->setCurrentIndex(0);
    16. PLCconfig->show();
    17. }
    18. else if(item==lnx)
    19. {
    20. ECLogic_Lnx=new eclogic_lnx(main_tab_widget);
    21. ECLogic_Lnx->setWindowTitle(QString("ECLOGIC-LNX"));
    22. ECLogic_Lnx->show();
    23. }
    24. }
    To copy to clipboard, switch view to plain text mode 
    Which does not make sense at all.

    EDIT:
    Oops now I found that there is another lnx variable which is class member - that would be better, but when you are creating new QTreeWidgetItem you are assigning it to the local variable with the same name (lnx) so your member variable lnx is always unassigned and referencing it will cause segmentation fault.

    Hi,
    Thankq.

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

    Red face Re: QTreeWidget clicked signal

    Hi All,
    i got my requirement from below code ,thanks all.

    Qt Code:
    1. void xxx::xxx()
    2. {
    3. ]if (item->data(0,Qt::UserRole) == "PLC")
    4. {
    5. PLCconfig=new plcconfiguration();
    6. scrollArea1=new QScrollArea;
    7. scrollArea1->setWidget(PLCconfig);
    8. main_tab_widget->insertTab(0,scrollArea1, "PLC");
    9. itemToWidget.insert(item,scrollArea1);
    10. widgetToItem.insert(scrollArea1,item);
    11. main_tab_widget->setCurrentIndex(0);
    12. PLCconfig->show();
    13. }
    To copy to clipboard, switch view to plain text mode 

    As i need to have many modifications in my project ,plz welcome my threads in near future.....
    thanks .
    Last edited by wysota; 30th January 2010 at 13:32. Reason: Missing [code] tags

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.