ctkMenuComboBoxTest3.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 <QComboBox>
  17. #include <QDebug>
  18. #include <QList>
  19. #include <QMenu>
  20. #include <QTimer>
  21. // CTK includes
  22. #include "ctkMenuComboBox.h"
  23. // STD includes
  24. #include <iostream>
  25. //-----------------------------------------------------------------------------
  26. int ctkMenuComboBoxTest3(int argc, char * argv [] )
  27. {
  28. QApplication app(argc, argv);
  29. ctkMenuComboBox menu;
  30. if (menu.menu())
  31. {
  32. qDebug() << "Line : " << __LINE__
  33. << " ctkMenuComboBox::ctkmenuComboBox failed"
  34. << menu.menu();
  35. return EXIT_FAILURE;
  36. }
  37. menu.setEditableBehavior(ctkMenuComboBox::Editable);
  38. QList<QComboBox* > comboBox = menu.findChildren<QComboBox *>();
  39. if (!comboBox[0]->isEditable())
  40. {
  41. qDebug() << "Line : " << __LINE__
  42. << "ctkMenuComboBox::setEditableBehavior failed";
  43. return EXIT_FAILURE;
  44. }
  45. menu.setEditableBehavior(ctkMenuComboBox::EditableOnFocus);
  46. if (comboBox[0]->isEditable())
  47. {
  48. qDebug() << "Line : " << __LINE__
  49. << "ctkMenuComboBox::setEditableBehavior failed";
  50. return EXIT_FAILURE;
  51. }
  52. menu.setEditableBehavior(ctkMenuComboBox::Editable);
  53. menu.setEditableBehavior(ctkMenuComboBox::NotEditable);
  54. if (comboBox[0]->isEditable())
  55. {
  56. qDebug() << "Line : " << __LINE__
  57. << "ctkMenuComboBox::setEditableBehavior failed";
  58. return EXIT_FAILURE;
  59. }
  60. menu.show();
  61. if (argc < 2 || QString(argv[1]) != "-I" )
  62. {
  63. QTimer::singleShot(200, &app, SLOT(quit()));
  64. }
  65. return app.exec();
  66. }