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. Invalid use of incomplete type 'class Ui::MainWindow' in default Qt Creator Hello world with QTabWidget added to mainwindow.ui
Forum Updated to NodeBB v4.3 + New Features

Invalid use of incomplete type 'class Ui::MainWindow' in default Qt Creator Hello world with QTabWidget added to mainwindow.ui

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 1.2k Views
  • 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.
  • enjoysmathE Offline
    enjoysmathE Offline
    enjoysmath
    wrote on last edited by enjoysmath
    #1

    To recreate:

    1. Create a new Qt Widgets application with a mainwindow.ui form and class etc.
    2. Add a QTabWidget from the form designer to the canvas (QMainWindow)
    3. Right-click on the QTabWidget and Layout > On a Grid.
    4. The default name is tabWidget as you can see in the properties panel. Leave the name alone.
    5. Create a member function in your QMainWindow class (the class template was already generated by Qt in step 1).
    6. Within that function, call ui->tabWidget.

    The line should be highlighted red indicating errors but you can also see it when you build in the build error output panel.

    invalid use of incomplete type 'class Ui::MainWindow'

    Is the first error, and other places when they don't say this will say that tabWidget is not a member of ui. So how do you access ui's members as created in the form designer?

    eaa025f1-0474-45eb-bfb0-ad1606626609-image.png

    JonBJ 1 Reply Last reply
    0
    • enjoysmathE Offline
      enjoysmathE Offline
      enjoysmath
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • enjoysmathE Offline
        enjoysmathE Offline
        enjoysmath
        wrote on last edited by
        #3

        Found reason: You can't do that addTabWidget definition in the class declartion, because of C++ limitation of forward class declarations I can only call ui->tabWidget in a .cpp defined function.

        VRoninV 1 Reply Last reply
        0
        • enjoysmathE enjoysmath

          To recreate:

          1. Create a new Qt Widgets application with a mainwindow.ui form and class etc.
          2. Add a QTabWidget from the form designer to the canvas (QMainWindow)
          3. Right-click on the QTabWidget and Layout > On a Grid.
          4. The default name is tabWidget as you can see in the properties panel. Leave the name alone.
          5. Create a member function in your QMainWindow class (the class template was already generated by Qt in step 1).
          6. Within that function, call ui->tabWidget.

          The line should be highlighted red indicating errors but you can also see it when you build in the build error output panel.

          invalid use of incomplete type 'class Ui::MainWindow'

          Is the first error, and other places when they don't say this will say that tabWidget is not a member of ui. So how do you access ui's members as created in the form designer?

          eaa025f1-0474-45eb-bfb0-ad1606626609-image.png

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

          @enjoysmath
          Please paste (not screenshot) the .cpp file you show, at least up to line #20. We need to see the i#includes at the start.

          Similarly, paste from your mainwindow.h, at least up to line #22-ish.

          1 Reply Last reply
          1
          • enjoysmathE enjoysmath

            Found reason: You can't do that addTabWidget definition in the class declartion, because of C++ limitation of forward class declarations I can only call ui->tabWidget in a .cpp defined function.

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            @enjoysmath said in Invalid use of incomplete type 'class Ui::MainWindow' in default Qt Creator Hello world with QTabWidget added to mainwindow.ui:

            Found reason: You can't do that addTabWidget definition in the class declartion, because of C++ limitation of forward class declarations I can only call ui->tabWidget in a .cpp defined function.

            This is not accurate, you can use it wherever you want but you have to #include "ui_mainwindow.h" first

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            4
            • N Offline
              N Offline
              nokede2571
              wrote on last edited by
              #6
              This post is deleted!
              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