Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. "WARNING: Cannot find style "test" - fallback: "default" "
Forum Updated to NodeBB v4.3 + New Features

"WARNING: Cannot find style "test" - fallback: "default" "

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 4 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    morita
    wrote on last edited by
    #1

    Hello.

    I curently have a problem about a way to use "Adding custom styles" of the "Virtual Keyboard".
    The error is "WARNING: Cannot find style "test" - fallback: "default" "

    I want to try to add custom styles to my project like :

    https://doc.qt.io/qt-5/technical-guide.html#keyboard-styles

    After reading the article, I tried to add custom styles including folder "test".

    And for my setting , I searched on the net and used below:
    https://forum.qt.io/topic/93279/how-to-custom-qml-virtual-keyboard/2

    Below is the most important points I checked in above the article.
    1.set the QT_VIRTUALKEYBOARD_STYLE to STYLENAME
    2.put the style.qml into your existing qrc (e.g. to the path :/kbstyles/test.qml :/kbstyles/QtQuick/VirtualKeyboard/Styles/STYLENAME/style.qml)
    3.add the import path to your QQmlEngine (engine->addImportPath(":/kbstyles"))

    But I had below the error.
    WARNING: Cannot find style "test" - fallback: "default"

    I do not know why I have the error. I guess I could correctly set above three rules.

    An below image is my source code.question_about_custom_style.PNG

    Could you tell me what is wrong ?

    1 Reply Last reply
    1
    • J Offline
      J Offline
      JR_Techno
      wrote on last edited by
      #2

      Same problem.

      R 1 Reply Last reply
      0
      • J JR_Techno

        Same problem.

        R Offline
        R Offline
        Rajeesh_Raveendran
        wrote on last edited by
        #3

        @JR_Techno got any solution? I have the same issue

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Elthik
          wrote on last edited by
          #4

          Hello.
          I encountered the same problem, found a solution.
          It's all about "qrc:/qt/qml". The search for the path "QtQuick/VirtualKeyboard/Styles" starts from there.
          Accordingly, if you created a resource file not in the root of the application, then you need to add the prefix "/qt/qml/" in the resource file to the directory to your keyboard style.
          Final structure (using my example):
          2ff8a16b-3a12-48cb-a6a2-85706f938733-image.png

          Main.cpp:

          int main(int argc, char *argv[])
          {
              qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
              qputenv("QT_VIRTUALKEYBOARD_STYLE", QByteArray("MXTS")); //Just style name, but before create QML engine!
          J
              QApplication app(argc, argv);
          
              ModelStorage* model = ModelStorage::instance();
          
              QQmlApplicationEngine engine;
          
              qDebug() << engine.importPathList(); // for exmaple: QList("C:/git/Torque_sub/TorqueSub/build/Desktop_Qt_6_8_2_MSVC2022_64bit-Debug", "qrc:/qt-project.org/imports", !!!!!"qrc:/qt/qml"!!!!!, "C:/Qt/6.8.2/msvc2022_64/qml")
          

          Style.qml:

          ......
          keyboardBackground: Rectangle {
                  color: "red"
              }
          ......
          

          Results:
          d6388f62-320a-4adc-a584-f6e2ca5eb821-image.png

          Ref. from src virtual keyboard qt git src:

          QString stylePath(const QString &name) const
              {
                  if (name.isEmpty())
                      return QString();
          
                  QStringList stylePathList;
                  stylePathList << QLatin1String("qrc:/qt-project.org/imports/QtQuick/VirtualKeyboard/Styles/Builtin/"); //###### default styles
                  const QStringList importPathList = qmlImportPathList(); //###### get import paths lists
                  // Add QML import path (Note: the QML base dir is usually the last entry in the list)
                  for (int i = importPathList.size() - 1; i >= 0; --i) {
                      const QString stylesPath = importPathList.at(i)
                          + QLatin1String("/QtQuick/VirtualKeyboard/Styles/");  //###### added, so path must:  qrc:/qt/qml/QtQuick/VirtualKeyboard/Styles
                      stylePathList += stylesPath;
                  }
          
                  // Path for backwards compatibility
                  stylePathList << QLatin1String("qrc:/QtQuick/VirtualKeyboard/content/styles/");
          
                  for (const QString &stylePath : std::as_const(stylePathList)) {
                      QString filePath = buildStyleFilePath(stylePath, name);
                      bool pathExist = false;
                      pathExist = QFileInfo::exists(filePath);
                      if (pathExist)
                          return buildStylePath(stylePath, name);
                  }
                  return QString();
              }
          

          Hopefully this will save someone an hour.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved