Important: Please read the Qt Code of Conduct -

Is that possible to use library from Qt4 in Qt5? [SOLVED]

  • The first solution that comes to mind - substitute all headers and functions that are not in use in Qt5. Like Phonon. In this case, how can I deal with lines that seems like don't have analogues in Qt5. For instance, what should I do with Phonon::Path, Phonon::AudioOutput etc. ?

    Otherwise, will it be a bad solution, if it's even possible of course, to add Phonon library to the project and compile with it?

  • @sosun

    The question is why you want to do this??

    AFAIK the functionality of Qt 4 shall be completely replaced by functionality of Qt 5.

    One thing coming to mind is the compiler issue between versions. You would be required to compile Qt 4 or Qt 5 yourself. Next point will be the eventually existing duplication of classes. Sounds all like a major task to me, if you like to plugin one of the old major libraries. With third party libs like Qwt it is different.

  • @koahnig You're right, I want to use 3rd party library - liblastfm. It requires 4.8. So, at the same time I want to be able to use functionality from Qt5 classes. Is there a way I can do this?

  • @sosun My approach would be trying to compile and try to link with Qt 5. Possibly there are only minor adjustments. However, that seems to be questionable. You should try to get feedback from the lastfm contributors. They will know and they might be interested to move forward and achieve compatibility with Qt 5.

    I do not know the internal details of Qt 4 and Qt 5 enough to give a final judgement. However, I expect that the Qt 4 part will require at least some core sections. Just imagining that the same core sections are still present in Qt 5, I do not think that there is a way. How should a linker decide which of the core objects shall be used?

    It is for sure that an easy task to mix those functionalities. This looks like a major development in my opinion. The route through getting the lastfm lib working with Qt 5 looks much easier IMHO.

  • Looking at the list of commits to liblastfm, there was some work done to get it working to work with Qt5. With just a quick glance, it's not clear to me if it was completed however.

  • @koahnig @mchinand Hm, thanks for the suggestions. I will ask developers about this opportunity. I'll put answers here as soon as developers will reply to my issue. Also, @mchinand, it's my fault I didn't notice commits about qt5-stuff, but what if I had used another 3rd party library based on Qt 4.x? This because question still has some value, but thank you for pointing me to this.

    ...Waiting answers from developers for posting it here...

  • @mchinand @koahnig Well, I've noticed that AUR has this library for building with qt5 named liblastfm-qt5-git. I think this is exactly what I need. I don't know why they didn't mention anything about it in the desctiption. Also, should I notify you when developers will reply?

  • @sosun Bascially with any 3rd party lib you will have the same issues. At the day's end it depends how deep thing are done. However, in most cases the adjustments to be done for Qt are moderate. I consider it merely a matter of time until things have been moved to Qt 5.

    This might be a pre-release only and they are still checking or it has been simply forgotten to update the description of lib.

    Personally, I think you should place at least a summary of the feedback you. Eventually you can links to more details, if the info is public anyway.

    [edit, koahnig] also a note when you succeed with or without developer's help is really useful.

  • Lifetime Qt Champion


    On the matter of mixing Qt 4 and Qt 5: don't even try. You'll have a symbol clash

  • @SGaist @koahnig @mchinand Thanks to all of you! They confirmed that library can be built with Qt5. Also, if we look at the CMakeLists.txt file, we'll find some lines like these:

    option(BUILD_WITH_QT4 "Build liblastfm with Qt4 no matter if Qt5 was found" OFF)
    if( NOT BUILD_WITH_QT4 )
        # try Qt5 first, and prefer that if found
        find_package(Qt5Core QUIET)
        message(STATUS "Found Qt5! Please keep in mind, this is highly experimental and not our main development target..")

    You can easily choose how to build library by switching OFF/ON keywords. I had to check it before asking ;)


    UPD: marked the issue as SOLVED

Log in to reply