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. `no member named ‘setupUi’`

`no member named ‘setupUi’`

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 319 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.
  • W Offline
    W Offline
    wiltors42
    wrote on last edited by
    #1

    Hi, I'm new to Qt. I couldn't find anything about this. I'm trying to setup QtDesigner and use a .ui file with C++ and CMAKE outside of QtCreator. I'm following this guide exactly but I'm still running into this problem. They want me to use forward declaration of MainWindow in Ui namespace but define it outside of the namespace, i.e.

    
    namespace Ui {
        class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
    ...
    

    But this gives me error: invalid use of incomplete type ‘class Ui::MainWindow’. When I use Ui:: for the class and member definitions I get this error. In fact, in both cases I get this error, with or without Ui::

    
    ‘class Ui::MainWindow’ has no member named ‘setupUi’
        8 |     ui->setupUi(this);
          |         ^~~~~~~
    
    

    Is this a linking problem or Qt problem? I can provide more info or my CMakeLists if necessary but it's almost exactly what's shown in that guide. Thanks.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      This is a source code problem. Your cpp file should #include the source generated by uic from your filename.ui file; usually a file called "ui_filename.h". This is what is shown in the mainwindow.cpp from your example.

      W 1 Reply Last reply
      3
      • C ChrisW67

        This is a source code problem. Your cpp file should #include the source generated by uic from your filename.ui file; usually a file called "ui_filename.h". This is what is shown in the mainwindow.cpp from your example.

        W Offline
        W Offline
        wiltors42
        wrote on last edited by
        #3

        @ChrisW67 Ohh. Thanks for pointing that out. I didn't get that the ui_x.h file was generated during compilation.

        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