Results 1 to 3 of 3

Thread: Please Help with QMainWindow Errors

  1. #1
    Join Date
    Apr 2014
    Location
    South Africa
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Please Help with QMainWindow Errors

    I got these errors after building the code below

    ..\RegistrationNumber\mainwindow.cpp: In constructor 'MainWindow::MainWindow(QWidget*)':
    ..\RegistrationNumber\mainwindow.cpp:15: error: 'class Ui::MainWindow' has no member named 'tableView'
    ..\RegistrationNumber\mainwindow.cpp:17: error: 'class Ui::MainWindow' has no member named 'tableView'
    ..\RegistrationNumber\mainwindow.cpp:19: error: 'class Ui::MainWindow' has no member named 'addButton'
    ..\RegistrationNumber\mainwindow.cpp: In member function 'void MainWindow::addNumber()':
    ..\RegistrationNumber\mainwindow.cpp:25: error: 'class Ui::MainWindow' has no member named 'province'
    ..\RegistrationNumber\mainwindow.cpp:26: error: 'class Ui::MainWindow' has no member named 'registrationNumber'
    ..\RegistrationNumber\mainwindow.cpp:28: error: 'class Ui::MainWindow' has no member named 'province'
    ..\RegistrationNumber\mainwindow.cpp:29: error: 'class Ui::MainWindow' has no member named 'registrationNumber'
    ..\RegistrationNumber\mainwindow.cpp:30: error: 'class Ui::MainWindow' has no member named 'province'
    ..\RegistrationNumber\mainwindow.cpp:33: error: 'number' was not declared in this scope
    mainwindow.cpp

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include <QRegExp>
    4. #include <QStringList>
    5. #include <QList>
    6. #include <QColor>
    7. #include <QMessageBox>
    8.  
    9. MainWindow::MainWindow(QWidget *parent) :
    10. QMainWindow(parent),
    11. ui(new Ui::MainWindow)
    12. {
    13. ui->setupUi(this);
    14. model = new RegistrationNumberModel(this);
    15. ui->tableView->setModel(model);
    16.  
    17. ui->tableView->horizontalHeader()->setStretchLastSection(true);
    18.  
    19. connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addNumber()));
    20.  
    21. }
    22.  
    23. void MainWindow::addNumber()
    24. {
    25. QString province = ui->province->text();
    26. QString registrationNumber = ui->registrationNumber->text();
    27.  
    28. ui->province->clear();
    29. ui->registrationNumber->clear();
    30. ui->province->setFocus();
    31.  
    32. NumberPlate *np = new NumberPlate(province, registrationNumber);
    33. number->addNumberPlate(np);
    34. }
    35.  
    36. MainWindow::~MainWindow()
    37. {
    38. delete ui;
    39. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Please Help with QMainWindow Errors

    Since when you are getting there errors?

    Did you just created a new MainWindow?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Please Help with QMainWindow Errors

    Ui::MainWindow is a generated class, the input for its generation is a .ui file that you edit in Qt Designer.
    Make sure it contains the elements you are referencing.

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 12th June 2014, 06:40
  2. Replies: 3
    Last Post: 13th November 2011, 08:12
  3. Replies: 0
    Last Post: 22nd September 2011, 10:31
  4. Replies: 2
    Last Post: 29th June 2011, 15:45
  5. Replies: 0
    Last Post: 17th November 2010, 17:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.