Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How to use KDE Frameworks with Qt Creator
QtWS25 Last Chance

How to use KDE Frameworks with Qt Creator

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
kdeqt5qtcreatormodule
8 Posts 5 Posters 6.2k 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.
  • D Offline
    D Offline
    daljit97
    wrote on last edited by
    #1

    On Linux (Ubuntu) there are two ways to install Qt, first is to use apt (sudo apt install qt5-default) and the other one is to download Qt from the official website. Now when you install using the first way Qt is installed by defualt /usr/lib and the second way in the home folder (or in /opt if you ran the installed with administrator privileges).
    Now I would like to integrate KDE Frameworks 5 in my project so on the official website it is suggested to use:

    sudo apt install framework

    And then you can just include that in your project by QT += framework. The problem is I installed Qt using the second way (downloading from the website) and as a result Qt Creator always return Project ERROR: Unknown module(s) in QT: framework. This I believe is because Qt doesn't seem to be aware of the fact that the modules are in /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/ instead it probably looks for them somewhere else.
    How do I solve this problem with a permanent solution? I cannot install Qt using apt because I would like to use the latest version which usually in not immediately available in the default repositories.

    Pablo J. RoginaP 1 Reply Last reply
    1
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by sierdzio
      #2

      I suppose you need to build from source https://community.kde.org/Guidelines_and_HOWTOs/Build_from_source

      Or (hacky!) move the files from /usr/lib into your /opt installation.

      BTW. You don't have to run Qt installer as administrator. Local, normal-user installation is also fine, and usually easier to work with.

      PS. You may also achieve some progress by using qt.conf https://doc.qt.io/qt-5/qt-conf.html although I doubt it.

      (Z(:^

      1 Reply Last reply
      2
      • D Offline
        D Offline
        daljit97
        wrote on last edited by daljit97
        #3

        Ok so for example I cloned KSyntaxHighlighting project from github and then installed kdesrc and built using kdesrc-build syntax-highlighting --include-dependencies (see here https://community.kde.org/Get_Involved/development#Set_up_kdesrc-build). Now the build succeded however how I do include the module in Qt Creator??? It still says module not found because I assume it's not looking in the correct directory (I can see the build folder in $HOME/kde/build)

        1 Reply Last reply
        0
        • D daljit97

          On Linux (Ubuntu) there are two ways to install Qt, first is to use apt (sudo apt install qt5-default) and the other one is to download Qt from the official website. Now when you install using the first way Qt is installed by defualt /usr/lib and the second way in the home folder (or in /opt if you ran the installed with administrator privileges).
          Now I would like to integrate KDE Frameworks 5 in my project so on the official website it is suggested to use:

          sudo apt install framework

          And then you can just include that in your project by QT += framework. The problem is I installed Qt using the second way (downloading from the website) and as a result Qt Creator always return Project ERROR: Unknown module(s) in QT: framework. This I believe is because Qt doesn't seem to be aware of the fact that the modules are in /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/ instead it probably looks for them somewhere else.
          How do I solve this problem with a permanent solution? I cannot install Qt using apt because I would like to use the latest version which usually in not immediately available in the default repositories.

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @daljit97 said in How to use KDE Frameworks with Qt Creator:

          QT += framework

          1. Are you sure that build KDE framework does indeed make a Qt module?
          2. And more important, does KDE install the module(s) where Qt looks for modules?

          I guess that what you have built for KDE are indeed and can be used as external libraries within a Qt project...

          LIBS += -L/path/to/your/library/ -lmylibrary
          

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          D 1 Reply Last reply
          0
          • Pablo J. RoginaP Pablo J. Rogina

            @daljit97 said in How to use KDE Frameworks with Qt Creator:

            QT += framework

            1. Are you sure that build KDE framework does indeed make a Qt module?
            2. And more important, does KDE install the module(s) where Qt looks for modules?

            I guess that what you have built for KDE are indeed and can be used as external libraries within a Qt project...

            LIBS += -L/path/to/your/library/ -lmylibrary
            
            D Offline
            D Offline
            daljit97
            wrote on last edited by
            #5

            @Pablo-J.-Rogina said in How to use KDE Frameworks with Qt Creator:

            Are you sure that build KDE framework does indeed make a Qt module?

            If you look here (bottom left of the page) the KDE documentations instruct that in order to use a KDE Framework with QMake you have to add QT += KSyntaxHighlighting.

            And more important, does KDE install the module(s) where Qt looks for modules?

            Well this is the problem, Qt doesn't seem to be aware of the modules and I am not sure how to fix that.
            I will try to suggest your suggestion, in order to build I followed this guide

            M aha_1980A 2 Replies Last reply
            0
            • D daljit97

              @Pablo-J.-Rogina said in How to use KDE Frameworks with Qt Creator:

              Are you sure that build KDE framework does indeed make a Qt module?

              If you look here (bottom left of the page) the KDE documentations instruct that in order to use a KDE Framework with QMake you have to add QT += KSyntaxHighlighting.

              And more important, does KDE install the module(s) where Qt looks for modules?

              Well this is the problem, Qt doesn't seem to be aware of the modules and I am not sure how to fix that.
              I will try to suggest your suggestion, in order to build I followed this guide

              M Offline
              M Offline
              mpyne
              wrote on last edited by
              #6

              Hi @daljit97, as you guessed, the difficulty is in helping Qt to find the appropriate metadata so that qmake knows how to handle "KSyntaxHighlighting" when it finds it in your QMake project file.

              Looking at some of the Qt docs on a related topic, I found this page on advanced QMake usage.

              The part you care about is the third option to add features to qmake: using the QMAKEPATH environment variable. By exporting this variable in your shell to the KF5 install directory, qmake should be able to find the various KF5 modules.

              For example, my KF5 install is at ~/kde-5, so I did something like:

              export QMAKEPATH=$HOME/kde-5
              qmake
              make
              

              on a shell project

              # program.pro
              TEMPLATE = app
              TARGET = program
              INCLUDEPATH += .
              QT += widgets KSyntaxHighlighting
              SOURCES += main.cpp
              
              // main.cpp
              #include <QMainWindow>
              #include <QApplication>
              #include <QLabel>
              #include <Definition>
              
              int main(int argc, char **argv)
              {
                  QApplication app(argc, argv);
              
                  QMainWindow *win = new QMainWindow;
                  KSyntaxHighlighting::Definition def;
              
                  win->setCentralWidget(
                          new QLabel(QStringLiteral("Hi!"), win)
                          );
                  win->show();
              
                  return app.exec();
              }
              

              It is also possible to build Qt applications with CMake, and that is more traditional for significant KF5 users. But as long as this works for you it looks like it won't be too hard to do what you're trying to do while continuing to use qmake.

              D 1 Reply Last reply
              5
              • D daljit97

                @Pablo-J.-Rogina said in How to use KDE Frameworks with Qt Creator:

                Are you sure that build KDE framework does indeed make a Qt module?

                If you look here (bottom left of the page) the KDE documentations instruct that in order to use a KDE Framework with QMake you have to add QT += KSyntaxHighlighting.

                And more important, does KDE install the module(s) where Qt looks for modules?

                Well this is the problem, Qt doesn't seem to be aware of the modules and I am not sure how to fix that.
                I will try to suggest your suggestion, in order to build I followed this guide

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @daljit97

                I'm not sure about the KDE frameworks, but for Qt modules there is a make install step that copies headers and libraries to the Qt installation, overwriting existing files if needed.

                On Linux, this will probably require root permissions, but afterwards the additional libs are part of your Qt installation and should work like every other Qt module.

                Regards

                Qt has to stay free or it will die.

                1 Reply Last reply
                2
                • M mpyne

                  Hi @daljit97, as you guessed, the difficulty is in helping Qt to find the appropriate metadata so that qmake knows how to handle "KSyntaxHighlighting" when it finds it in your QMake project file.

                  Looking at some of the Qt docs on a related topic, I found this page on advanced QMake usage.

                  The part you care about is the third option to add features to qmake: using the QMAKEPATH environment variable. By exporting this variable in your shell to the KF5 install directory, qmake should be able to find the various KF5 modules.

                  For example, my KF5 install is at ~/kde-5, so I did something like:

                  export QMAKEPATH=$HOME/kde-5
                  qmake
                  make
                  

                  on a shell project

                  # program.pro
                  TEMPLATE = app
                  TARGET = program
                  INCLUDEPATH += .
                  QT += widgets KSyntaxHighlighting
                  SOURCES += main.cpp
                  
                  // main.cpp
                  #include <QMainWindow>
                  #include <QApplication>
                  #include <QLabel>
                  #include <Definition>
                  
                  int main(int argc, char **argv)
                  {
                      QApplication app(argc, argv);
                  
                      QMainWindow *win = new QMainWindow;
                      KSyntaxHighlighting::Definition def;
                  
                      win->setCentralWidget(
                              new QLabel(QStringLiteral("Hi!"), win)
                              );
                      win->show();
                  
                      return app.exec();
                  }
                  

                  It is also possible to build Qt applications with CMake, and that is more traditional for significant KF5 users. But as long as this works for you it looks like it won't be too hard to do what you're trying to do while continuing to use qmake.

                  D Offline
                  D Offline
                  daljit97
                  wrote on last edited by daljit97
                  #8

                  @mpyne said in How to use KDE Frameworks with Qt Creator:

                  Hi @daljit97, as you guessed, the difficulty is in helping Qt to find the appropriate metadata so that qmake knows how to handle "KSyntaxHighlighting" when it finds it in your QMake project file.

                  Looking at some of the Qt docs on a related topic, I found this page on advanced QMake usage.

                  The part you care about is the third option to add features to qmake: using the QMAKEPATH environment variable. By exporting this variable in your shell to the KF5 install directory, qmake should be able to find the various KF5 modules.

                  For example, my KF5 install is at ~/kde-5, so I did something like:

                  export QMAKEPATH=$HOME/kde-5
                  qmake
                  make
                  

                  on a shell project

                  # program.pro
                  TEMPLATE = app
                  TARGET = program
                  INCLUDEPATH += .
                  QT += widgets KSyntaxHighlighting
                  SOURCES += main.cpp
                  
                  // main.cpp
                  #include <QMainWindow>
                  #include <QApplication>
                  #include <QLabel>
                  #include <Definition>
                  
                  int main(int argc, char **argv)
                  {
                      QApplication app(argc, argv);
                  
                      QMainWindow *win = new QMainWindow;
                      KSyntaxHighlighting::Definition def;
                  
                      win->setCentralWidget(
                              new QLabel(QStringLiteral("Hi!"), win)
                              );
                      win->show();
                  
                      return app.exec();
                  }
                  

                  It is also possible to build Qt applications with CMake, and that is more traditional for significant KF5 users. But as long as this works for you it looks like it won't be too hard to do what you're trying to do while continuing to use qmake.

                  Ok so that was very helpful. On my machine that KSyntaxHighlighting had a .pri file in /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules. Following your suggestion I added a QMAKEPATH Environment variable in Qt Creator using the GUI tool that Qt Creator provides and now everything works!
                  0_1562930894756_Screenshot from 2019-07-12 12-27-19.png

                  1 Reply Last reply
                  4

                  • Login

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