Results 1 to 4 of 4

Thread: QTreeList.. Everything is ok but??

  1. #1
    Join Date
    Jun 2008
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default QTreeList.. Everything is ok but??

    All my code is correct. It compiles the program and it also works but
    I can none of my frames on the panel. I can see only an empty panel.

    Is there any incorrect thing in the code?? or may ı forget any "show " or "set" words??
    I couldn't see my error. Please help me.



    Qt Code:
    1. #ifndef UI_NEW_H
    2. #define UI_NEW_H
    3.  
    4. #include <QtCore/QVariant>
    5. #include <QtGui/QAction>
    6. #include <QtGui/QApplication>
    7. #include <QtGui/QButtonGroup>
    8. #include <QtGui/QLabel>
    9. #include <QtGui/QWidget>
    10. #include "mylineedit.h"
    11. #include "mylistwidget.h"
    12. #include "mytreewidget.h"
    13.  
    14. class Ui_myFormDLG
    15. {
    16. public:
    17. myTreeWidget *treeWidget;
    18. myListWidget *listWidget;
    19. QLabel *label_3;
    20. QLabel *label;
    21.  
    22. myLineEdit *lineEdit;
    23.  
    24. void setupUi(QWidget *myFormDLG)
    25. {
    26. if (myFormDLG->objectName().isEmpty())
    27. myFormDLG->setObjectName(QString::fromUtf8("myFormDLG"));
    28. myFormDLG->resize(447, 359);
    29.  
    30. treeWidget = new myTreeWidget(myFormDLG);
    31. treeWidget->setObjectName(QString::fromUtf8("treeWidget"));
    32. treeWidget->setGeometry(QRect(10, 70, 271, 271));
    33.  
    34. QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    35. sizePolicy.setHorizontalStretch(0);
    36. sizePolicy.setVerticalStretch(0);
    37. sizePolicy.setHeightForWidth(treeWidget->sizePolicy().hasHeightForWidth());
    38.  
    39. treeWidget->setSizePolicy(sizePolicy);
    40. treeWidget->setAcceptDrops(true);
    41. treeWidget->setDragDropOverwriteMode(true);
    42.  
    43. listWidget = new myListWidget(myFormDLG);
    44. listWidget->setObjectName(QString::fromUtf8("listWidget"));
    45. listWidget->setGeometry(QRect(290, 70, 141, 271));
    46.  
    47. QSizePolicy sizePolicy1(QSizePolicy::Ignored, QSizePolicy::Ignored);
    48. sizePolicy1.setHorizontalStretch(0);
    49. sizePolicy1.setVerticalStretch(0);
    50. sizePolicy1.setHeightForWidth(listWidget->sizePolicy().hasHeightForWidth());
    51.  
    52. listWidget->setSizePolicy(sizePolicy1);
    53. listWidget->setAcceptDrops(true);
    54. listWidget->setDragEnabled(true);
    55.  
    56. label_3 = new QLabel(myFormDLG);
    57. label_3->setObjectName(QString::fromUtf8("label_3"));
    58. label_3->setGeometry(QRect(290, 50, 131, 21));
    59. label = new QLabel(myFormDLG);
    60. label->setObjectName(QString::fromUtf8("label"));
    61. label->setGeometry(QRect(10, 46, 241, 21));
    62.  
    63.  
    64. lineEdit = new myLineEdit(myFormDLG);
    65. lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
    66. lineEdit->setGeometry(QRect(80, 10, 351, 22));
    67.  
    68. retranslateUi(myFormDLG);
    69.  
    70. QMetaObject::connectSlotsByName(myFormDLG);
    71. } // setupUi
    72.  
    73. void retranslateUi(QWidget *myFormDLG)
    74. {
    75. myFormDLG->setWindowTitle(QApplication::translate("myFormDLG", "This is my form", 0, QApplication::UnicodeUTF8));
    76. treeWidget->headerItem()->setText(0, QApplication::translate("myFormDLG", "One and only column", 0, QApplication::UnicodeUTF8));
    77. treeWidget->clear();
    78.  
    79. QTreeWidgetItem *__item = new QTreeWidgetItem(treeWidget);
    80. __item->setText(0, QApplication::translate("myFormDLG", "Item 1", 0, QApplication::UnicodeUTF8));
    81.  
    82. QTreeWidgetItem *__item1 = new QTreeWidgetItem(__item);
    83. __item1->setText(0, QApplication::translate("myFormDLG", "Subitem 1.1", 0, QApplication::UnicodeUTF8));
    84.  
    85. QTreeWidgetItem *__item2 = new QTreeWidgetItem(__item);
    86. __item2->setText(0, QApplication::translate("myFormDLG", "Subitem 1.2", 0, QApplication::UnicodeUTF8));
    87.  
    88. QTreeWidgetItem *__item3 = new QTreeWidgetItem(__item2);
    89. __item3->setText(0, QApplication::translate("myFormDLG", "Subitem 1.2.1", 0, QApplication::UnicodeUTF8));
    90.  
    91. QTreeWidgetItem *__item4 = new QTreeWidgetItem(treeWidget);
    92. __item4->setText(0, QApplication::translate("myFormDLG", "Item 2", 0, QApplication::UnicodeUTF8));
    93. listWidget->clear();
    94.  
    95. QListWidgetItem *__item5 = new QListWidgetItem(listWidget);
    96. __item5->setText(QApplication::translate("myFormDLG", "item 1", 0, QApplication::UnicodeUTF8));
    97.  
    98. QListWidgetItem *__item6 = new QListWidgetItem(listWidget);
    99. __item6->setText(QApplication::translate("myFormDLG", "item 2", 0, QApplication::UnicodeUTF8));
    100.  
    101. QListWidgetItem *__item7 = new QListWidgetItem(listWidget);
    102. __item7->setText(QApplication::translate("myFormDLG", "item 3", 0, QApplication::UnicodeUTF8));
    103.  
    104. QListWidgetItem *__item8 = new QListWidgetItem(listWidget);
    105. __item8->setText(QApplication::translate("myFormDLG", "item 4", 0, QApplication::UnicodeUTF8));
    106.  
    107. QListWidgetItem *__item9 = new QListWidgetItem(listWidget);
    108. __item9->setText(QApplication::translate("myFormDLG", "item 5", 0, QApplication::UnicodeUTF8));
    109. label_3->setText(QApplication::translate("myFormDLG", "listWidget", 0, QApplication::UnicodeUTF8));
    110. label->setText(QApplication::translate("myFormDLG", "treeWidget", 0, QApplication::UnicodeUTF8));
    111.  
    112. Q_UNUSED(myFormDLG);
    113. } // retranslateUi
    114.  
    115. };
    116.  
    117. namespace Ui {
    118. class myFormDLG: public Ui_myFormDLG {};
    119. } // namespace Ui
    120.  
    121. #endif // UI_NEW_H
    To copy to clipboard, switch view to plain text mode 





    Qt Code:
    1. #include "myqtapp.h"
    2.  
    3.  
    4. myQtApp::myQtApp(QWidget *parent): QWidget(parent)
    5. {
    6. //myQtApp parent2;
    7. ui.setupUi( this ); // sets up GUI
    8. //parent2.show();
    9.  
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mytreewidget.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. myTreeWidget w;
    8. w.show();
    9. a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
    10. return a.exec();
    11.  
    12.  
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 11th July 2008 at 08:43. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeList.. Everything is ok but??

    What's the difference between myTreeWidget and myQtApp?

  3. #3
    Join Date
    Jun 2008
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeList.. Everything is ok but??

    Quote Originally Posted by jacek View Post
    What's the difference between myTreeWidget and myQtApp?
    In mytreewidget class, it makes new QTreeWidgetItem and set its text if parent is null - add top level item (this parent).

    but myqtapp class just sets up the GUI

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeList.. Everything is ok but??

    Quote Originally Posted by rrrrcem View Post
    In mytreewidget class, it makes new QTreeWidgetItem and set its text if parent is null - add top level item (this parent).

    but myqtapp class just sets up the GUI
    OK, but in main() you create the tree widget, not the myQtApp instance.

Similar Threads

  1. selecting a specific QtreeList item
    By MrGarbage in forum Qt Programming
    Replies: 1
    Last Post: 9th October 2007, 13:45

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.