Hello,

I switched from Qt 4 to Qt 5 and everything is working, but all buttons from QDialogButtonBox are not translating


This is my cmake:

Qt Code:
  1. set (TRANSLATION_SRCS
  2. qt_pl.ts
  3. scc_pl.ts
  4. )
  5.  
  6. set (TRANSLATION_QM
  7. qt_pl.qm
  8. scc_pl.qm
  9. )
  10.  
  11. # translation
  12. qt5_add_translation (TRANSLATION_FILES ${TRANSLATION_SRCS})
  13. add_custom_target (translations DEPENDS ${TRANSLATION_FILES})
  14.  
  15. # translations
  16. add_dependencies (scc translations)
  17.  
  18. # install
  19. if (UNIX AND NOT APPLE)
  20. install (FILES ${TRANSLATION_QM} DESTINATION ${SCC_DATA_DIR}/translations)
  21. endif (UNIX AND NOT APPLE)
To copy to clipboard, switch view to plain text mode 

how I load translate (with debug)
Qt Code:
  1. // load translate
  2. QString q = QString("qt_%1").arg(strLanguage);
  3. qDebug() << "path:" << q;
  4. bool load = qtTranslator.load(q, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
  5. qDebug() << "load:" << load;
  6. if (load)
  7. qApp->installTranslator(&qtTranslator);
  8.  
  9. if (sccTranslator.load(QString("%1/translations/scc_%2").arg(path, strLanguage)))
  10. qApp->installTranslator(&sccTranslator);
To copy to clipboard, switch view to plain text mode 

debug result:
Qt Code:
  1. path: "qt_pl"
  2. load: true
To copy to clipboard, switch view to plain text mode 

Normal load translate:
Qt Code:
  1. // load translate
  2. if (qtTranslator.load(QString("%1/translations/qt_%2").arg(path, strLanguage)))
  3. qApp->installTranslator(&qtTranslator);
  4.  
  5. if (sccTranslator.load(QString("%1/translations/scc_%2").arg(path, strLanguage)))
  6. qApp->installTranslator(&sccTranslator);
To copy to clipboard, switch view to plain text mode 

main cmake:
Qt Code:
  1. # Tell CMake to run moc when necessary:
  2. set(CMAKE_AUTOMOC ON)
  3.  
  4. # As moc files are generated in the binary dir, tell CMake
  5. # to always look for includes there:
  6. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  7.  
  8. # qt
  9. find_package(Qt5Widgets)
  10. find_package(Qt5Multimedia)
  11. find_package(Qt5Network)
  12. #find_package(Qt5LinguistTools)
  13. find_package(Qt5WebKit)
  14. find_package(Qt5WebKitWidgets)
  15. find_package(Qt5Xml)
  16.  
  17. # include qt qtnetwork
  18. include_directories (
  19. ${CMAKE_BINARY_DIR}
  20. ${CMAKE_CURRENT_SOURCE_DIR}/common
  21. ${CMAKE_CURRENT_SOURCE_DIR}/core
  22. ${CMAKE_CURRENT_SOURCE_DIR}/gui
  23. ${CMAKE_CURRENT_SOURCE_DIR}/models
  24. ${CMAKE_CURRENT_SOURCE_DIR}/onet
  25. ${CMAKE_CURRENT_SOURCE_DIR}/tab
  26. ${CMAKE_CURRENT_SOURCE_DIR}/widgets
  27. )
  28.  
  29. # resources
  30. set (scc_QRC ../scc.qrc)
  31. qt5_add_resources (scc_QRC_SRCS ${scc_QRC})
  32.  
  33. # ui
  34. qt5_wrap_ui (scc_UIS_H ${scc_UIS})
  35.  
  36. # moc
  37. qt5_generate_moc (scc MOC_FILES ${scc_MOC_HDRS})
  38.  
  39. # resource
  40. set (scc_RESOURCE ../scc_mingw.rc)
  41.  
  42. include_directories (${CMAKE_SOURCE_DIR}/ui)
  43.  
  44. # link
  45. if (MINGW) # mingw
  46. add_executable (scc ${scc_SRCS} ${MOC_FILES} ${scc_HDRS} ${scc_QRC_SRCS} ${scc_UIS_H} ${scc_RESOURCE})
  47. else (MINGW) # linux
  48. add_executable (scc ${scc_SRCS} ${MOC_FILES} ${scc_HDRS} ${scc_QRC_SRCS} ${scc_UIS_H})
  49. endif (MINGW)
  50.  
  51. target_link_libraries (scc Qt5::Widgets Qt5::Multimedia Qt5::Network Qt5::WebKit Qt5::WebKitWidgets Qt5::Xml ${QCA2_LIBRARIES})
  52.  
  53. # install
  54. if (UNIX AND NOT APPLE)
  55. install (TARGETS scc DESTINATION ${SCC_BIN_DIR})
  56. endif (UNIX AND NOT APPLE)
To copy to clipboard, switch view to plain text mode 

How it looks in qt creator: (good-translated)
Attachment 10498

and how it looks in application: (wrong-not translated)
Attachment 10499

so, what I do wrong ?
and why load returns true and button is not translated ?

I'm using Qt 5.3.1 mingw