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. QDialog compilation error
Forum Updated to NodeBB v4.3 + New Features

QDialog compilation error

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.2k Views 2 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.
  • M Offline
    M Offline
    matthewkerr
    wrote on last edited by
    #1

    Hi. I'm sure this is a really simple question.

    I've created a Qt Widget Application.
    I then created a QDialog which is to be an About dialog. I used the Qt Designer Form Class and went with a Dialog with Buttons. I only wanted the OK button, and couldn't work out how to remove the Cancel button, so I deleted the buttons and added an OK button.
    So far so good.

    I then made the following changes to my QMainWindow header file:
    Forward declared my Ui::About class.
    Added a Ui::About member variable.

    I then made the following changes to my QMainWindow CPP file:
    #include "about.h"
    Added to the constructor body:
    about = new Ui::About(this);

    When I compile I get the error:
    'Ui::About' : class has no constructors

    It's as if I'm using the wrong #include in the QMainWindow CPP file.

    If I also add #include "ui_about.h" I get a different error:
    'Ui::About::About(const Ui::About &)' : cannot convert argument 1 from 'TargetController *const ' to 'const Ui::About &'
    Reason: cannot convert from 'TargetController *const ' to 'const Ui::About'
    No constructor could take the source type, or constructor overload resolution was ambiguous

    I think I'm misunderstanding the something simple.

    Matt.

    kshegunovK 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Normally you would just include the AboutDialog.h
      and
      AboutDialog dia;
      dia.exec()
      to show it.

      The Ui::About is used internally in the Dialog in the constructor.
      So you just construct an instance of your dialog class and it should just work.

      1 Reply Last reply
      3
      • M matthewkerr

        Hi. I'm sure this is a really simple question.

        I've created a Qt Widget Application.
        I then created a QDialog which is to be an About dialog. I used the Qt Designer Form Class and went with a Dialog with Buttons. I only wanted the OK button, and couldn't work out how to remove the Cancel button, so I deleted the buttons and added an OK button.
        So far so good.

        I then made the following changes to my QMainWindow header file:
        Forward declared my Ui::About class.
        Added a Ui::About member variable.

        I then made the following changes to my QMainWindow CPP file:
        #include "about.h"
        Added to the constructor body:
        about = new Ui::About(this);

        When I compile I get the error:
        'Ui::About' : class has no constructors

        It's as if I'm using the wrong #include in the QMainWindow CPP file.

        If I also add #include "ui_about.h" I get a different error:
        'Ui::About::About(const Ui::About &)' : cannot convert argument 1 from 'TargetController *const ' to 'const Ui::About &'
        Reason: cannot convert from 'TargetController *const ' to 'const Ui::About'
        No constructor could take the source type, or constructor overload resolution was ambiguous

        I think I'm misunderstanding the something simple.

        Matt.

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #3
        ui = new Ui::Notepad;
        ui->setupUi(this);
        

        Here there's a full example: http://doc.qt.io/qt-5/gettingstartedqt.html

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        2

        • Login

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