ctkDirectoryButtonTest1.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.commontk.org/LICENSE
  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 <QTimer>
  17. // CTK includes
  18. #include "ctkDirectoryButton.h"
  19. // STD includes
  20. #include <cstdlib>
  21. #include <iostream>
  22. //-----------------------------------------------------------------------------
  23. int ctkDirectoryButtonTest1(int argc, char * argv [] )
  24. {
  25. QApplication app(argc, argv);
  26. ctkDirectoryButton ctkObject;
  27. #if QT_VERSION >= 0x040700
  28. ctkObject.setOptions(QFileDialog::ShowDirsOnly | QFileDialog::ReadOnly);
  29. #else
  30. ctkObject.setOptions(ctkDirectoryButton::ShowDirsOnly |
  31. ctkDirectoryButton::ReadOnly);
  32. #endif
  33. ctkObject.show();
  34. QTimer autoExit;
  35. if (argc < 2 || QString(argv[1]) != "-I")
  36. {
  37. QObject::connect(&autoExit, SIGNAL(timeout()), &app, SLOT(quit()));
  38. autoExit.start(100);
  39. }
  40. return app.exec();
  41. }