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 550 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 10 Feb 2021, 07:45 last edited by BoboFuego 2 Oct 2021, 07:45
    #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
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 10 Feb 2021, 08:05 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(:^

      J 1 Reply Last reply 10 Feb 2021, 08:07
      0
      • S sierdzio
        10 Feb 2021, 08:05

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

        J Offline
        J Offline
        JonB
        wrote on 10 Feb 2021, 08:07 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 1 Reply Last reply 10 Feb 2021, 08:09
        0
        • J JonB
          10 Feb 2021, 08:07

          @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 Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 10 Feb 2021, 08:09 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

          3/4

          10 Feb 2021, 08:07

          • Login

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