ctkSettingsPanelTest2.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 <QSettings>
  17. // CTK includes
  18. #include "ctkSettingsPanel.h"
  19. #include "ctkSettingsPanelTest2Helper.h"
  20. // STD includes
  21. #include <cstdlib>
  22. #include <iostream>
  23. //-----------------------------------------------------------------------------
  24. int ctkSettingsPanelTest2(int argc, char * argv [] )
  25. {
  26. QApplication app(argc, argv);
  27. Q_UNUSED(app);
  28. {
  29. // When QSettings goes out of scope, we are the settings file is up-to-date
  30. QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Common ToolKit", "CTK");
  31. settings.clear();
  32. settings.setValue("list", QVariant(QStringList()));
  33. }
  34. // Regression: Reading empty QStringList property from settings should be handled properly
  35. ctkSettingsPanel settingsPanel;
  36. ctkSettingsPanelTest2Helper * list = new ctkSettingsPanelTest2Helper(&settingsPanel);
  37. settingsPanel.registerProperty("list", list, "list", SIGNAL(listChanged()));
  38. QSettings settings2(QSettings::IniFormat, QSettings::UserScope, "Common ToolKit", "CTK");
  39. settingsPanel.setSettings(&settings2);
  40. return EXIT_SUCCESS;
  41. }