Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved How to move the definitions from mainwindow.cpp to mainwindow.h?

    General and Desktop
    template ui header uiautomator
    4
    4
    229
    Loading More Posts
    • 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.
    • B
      BoboFuego last edited by BoboFuego

      I want to define the class MainWindow as a template class, but I cannot move the definitions of its functions to mainwindow.h because of the forward declaration of namespace Ui { class MainWindow; }. How to achieve such a thing? Appreciate any help or suggestions

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        Find a different approach. QObject classes cannot be templated, so it won't work even if you solve namespace Ui problem.

        (Z(:^

        JonB 1 Reply Last reply Reply Quote 0
        • JonB
          JonB @sierdzio last edited by

          @sierdzio said in How to move the definitions from mainwindow.cpp to mainwindow.h?:

          QObject classes cannot be templated

          Could you say a few more words about this, please?

          J.Hilk 1 Reply Last reply Reply Quote 0
          • J.Hilk
            J.Hilk Moderators @JonB last edited by

            @JonB the problem is the Meta-Object-Compiler it can't create the magic code to make signal&slots and macros work

            you could use Verdigris if you really, really need templated QObject classes

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply Reply Quote 3
            • First post
              Last post