Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to move the definitions from mainwindow.cpp to mainwindow.h?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
templateui headeruiautomator
4 Posts 4 Posters 561 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.
  • B Offline
    B Offline
    BoboFuego
    wrote on last edited by BoboFuego
    #1

    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
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

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

      (Z(:^

      JonBJ 1 Reply Last reply
      0
      • sierdzioS sierdzio

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

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @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.HilkJ 1 Reply Last reply
        0
        • JonBJ JonB

          @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.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @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


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

          1 Reply Last reply
          3

          • Login

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