Dan3460
Dan3460

Reputation: 95

QDate has incomplete type, declaring as private member

I'm trying to create two private variables type date on a class but i'm getting the error "field 'date1' has incomplete type 'QDate'". I made an empty test application to show the problem.

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
  class MainWindow;
}

class MainWindow : public QMainWindow
{
  Q_OBJECT

public:
  explicit MainWindow(QWidget *parent = 0);
  ~MainWindow();

private:
  Ui::MainWindow *ui;

  QDate date1;  <<---- Problem here
  QDate date2;
};

#endif // MAINWINDOW_H

Is there a special way to declare date variables?

Upvotes: 0

Views: 2534

Answers (1)

Taha Tekdoğan
Taha Tekdoğan

Reputation: 167

After adding the header

#include <QDate>

you can initialize them like this:

QDate date1(1995,2,2);

Upvotes: 1

Related Questions