Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Moving from Qt4 to Qt5 - linker problem. Explicit instantiations problem or (hopefully) something else?
Forum Updated to NodeBB v4.3 + New Features

Moving from Qt4 to Qt5 - linker problem. Explicit instantiations problem or (hopefully) something else?

Scheduled Pinned Locked Moved Installation and Deployment
2 Posts 1 Posters 606 Views 1 Watching
  • 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.
  • A Offline
    A Offline
    applefier
    wrote on last edited by
    #1

    The following compiled, linked and worked with qmake-qt4. With qmake the linker fails with message undefined reference to `void TabScreen::addNewScreen<ScreenA>(ScreenA*, Qt::Orientation)'

    Is this a result of differences between Qt4 and Qt5 which means I will have to change the code or is it something simpler, like my error in moving the code to Qt5? The only difference in project files is the extra line QT+=widgets added to the Qt5.

    tabScreen.h
    @class TabScreen : public QFrame
    {
    public:
    template<class ScreenType>
    void addNewScreen(ScreenType *, Qt::Orientation);
    };
    @

    tabScreen.cpp
    @
    #include "tabScreen.h"
    #include "screenControl.h"

    template<class ScreenType, class NewScreenType>
    void TabScreen::changeScreenLayout(ScreenType * screen, NewScreenType * newScreen, Qt::Orientation orientation)
    {
    // calls Fn from screenControl.h (below)
    ScreenLayoutControl<TabScreen>::addScreen(screen,newScreen,orientation);
    }

    template<class ScreenType>
    void TabScreen::addNewScreen(ScreenType * screen, Qt::Orientation orientation)
    {
    changeScreenLayout(screen, new ScreenChooser(this), orientation);
    }
    @

    screenControl.h
    @
    #include "tabScreen.h"

    template<class ParentType>
    struct ScreenLayoutControl
    {
    template<class ScreenType, class NewScreenType>
    void static addScreen(ScreenType * s1, NewScreenType * s2, Qt::Orientation orientation)
    {
    // do stuff
    }
    // ...
    }

    template<>
    struct ScreenLayoutControl<BaseScreen>
    {
    template<class ScreenType, class NewScreenType>
    void static addScreen(ScreenType * s1, NewScreenType * s2, Qt::Orientation orientation)
    {
    // do stuff
    }
    // ...
    }
    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      applefier
      wrote on last edited by
      #2

      Never mind, it was explicit instantiations. Problem solved.

      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