ctkExpandableWidgetTest1.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // Qt includes
  15. #include <QApplication>
  16. #include <QDebug>
  17. #include <QGroupBox>
  18. #include <QLabel>
  19. #include <QListView>
  20. #include <QStyle>
  21. #include <QTableView>
  22. #include <QTimer>
  23. #include <QTreeView>
  24. #include <QVBoxLayout>
  25. #if (QT_VERSION < 0x50000)
  26. #include <QPlastiqueStyle>
  27. #endif
  28. // CTK includes
  29. #include "ctkExpandableWidget.h"
  30. // STD includes
  31. #include <cstdlib>
  32. #include <iostream>
  33. //-----------------------------------------------------------------------------
  34. int ctkExpandableWidgetTest1(int argc, char * argv [] )
  35. {
  36. #if (QT_VERSION < 0x50000)
  37. QApplication::setStyle(new QPlastiqueStyle);
  38. #endif
  39. QApplication app(argc, argv);
  40. QWidget topLevel;
  41. QHBoxLayout* topLevelLayout = new QHBoxLayout;
  42. topLevel.setLayout(topLevelLayout);
  43. QWidget frame;
  44. topLevelLayout->addWidget(&frame);
  45. ctkExpandableWidget resizableFrame1(&frame);
  46. QListView* listView = new QListView(&resizableFrame1);
  47. listView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
  48. QVBoxLayout* resizableFrameLayout1 = new QVBoxLayout(&resizableFrame1);
  49. resizableFrameLayout1->setContentsMargins(0,0,0,0);
  50. resizableFrame1.setSizeGripMargins(QSize(2, 2));
  51. resizableFrame1.setLayout(resizableFrameLayout1);
  52. resizableFrameLayout1->addWidget(listView);
  53. resizableFrame1.setOrientations(Qt::Horizontal | Qt::Vertical);
  54. ctkExpandableWidget resizableFrame(&frame);
  55. resizableFrame.setSizeGripInside(false);
  56. QTreeView* treeView = new QTreeView(&resizableFrame);
  57. treeView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
  58. QVBoxLayout* resizableFrameLayout = new QVBoxLayout(&resizableFrame);
  59. resizableFrameLayout->setContentsMargins(0,0,0,0);
  60. //resizableFrame.setSizeGripMargins(QSize(2, 2));
  61. resizableFrame.setLayout(resizableFrameLayout);
  62. resizableFrameLayout->addWidget(treeView);
  63. resizableFrame.setOrientations(Qt::Horizontal);
  64. QVBoxLayout *vbox = new QVBoxLayout;
  65. vbox->setContentsMargins(0, 0, 0, 0);
  66. vbox->addWidget(&resizableFrame1);
  67. vbox->addWidget(&resizableFrame);
  68. frame.setLayout(vbox);
  69. ctkExpandableWidget resizableFrame0(&topLevel);
  70. QTableView* tableView = new QTableView(&resizableFrame0);
  71. tableView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
  72. QVBoxLayout* resizableFrameLayout0 = new QVBoxLayout(&resizableFrame0);
  73. resizableFrameLayout0->setContentsMargins(0,0,0,0);
  74. resizableFrame0.setSizeGripMargins(QSize(2, 2));
  75. resizableFrame0.setLayout(resizableFrameLayout0);
  76. resizableFrameLayout0->addWidget(tableView);
  77. resizableFrame0.setOrientations(Qt::Vertical);
  78. topLevelLayout->addWidget(&resizableFrame0);
  79. topLevel.show();
  80. if (argc < 2 || QString(argv[1]) != "-I" )
  81. {
  82. QTimer::singleShot(200, &app, SLOT(quit()));
  83. }
  84. return app.exec();
  85. }