[Qt] Subokno programu

0

W jaki sposób otworzyć subokno programu np. konfiguracji lub administracji grupami?
Część mainwindow.cpp:

#include "_teamslist.cpp"

void MainWindow::teamsList()
{
    teamsList tL;
    tL.show();
}

_teamslist.cpp:

#include "_teamslist.h"
#include "ui__teamslist.h"

teamsList::teamsList(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::teamsList)
{
    ui->setupUi(this);
    this->setWindowTitle(lng.teamsListTitle);
}

teamsList::~teamsList()
{
    delete ui;
}

void teamsList::changeEvent(QEvent *e)
{
    QWidget::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

_teamslist.h:

#ifndef _TEAMSLIST_H
#define _TEAMSLIST_H

#include <QtGui/QWidget>

namespace Ui {
    class teamsList;
}

class teamsList : public QWidget {
    Q_OBJECT
public:
    teamsList(QWidget *parent = 0);
    ~teamsList();

protected:
    void changeEvent(QEvent *e);

private:
    Ui::teamsList *ui;
};

#endif // _TEAMSLIST_H

Efekt:

mainwindow.cpp:92: error: expected ';' before 'tL'
mainwindow.cpp:92: error: statement cannot resolve address of overloaded function
mainwindow.cpp:93: error: 'tL' was not declared in this scope

Co jest źle?

0

Czy przypadkiem w mainwindow.cpp nie powinieneś zrobić

 #include "_teamslist.h" 

zamiast

#include "_teamslist.cpp"

??
W pliku teamslist.cpp nie masz deklaracji ani definicji klasy.

0

Zmieniłem, ale nadal są te same błędy.
mainwindow.cpp:

#include "_teamslist.h"

_teamslist.h:

#ifndef _TEAMSLIST_H
#define _TEAMSLIST_H
#include "ui__teamslist.h"
#include <QDialog>

namespace Ui {
    class teamsList;
}

class teamsList : public QDialog {
    Q_OBJECT
public:
    teamsList(QWidget *parent = 0);
    ~teamsList();

protected:
    void changeEvent(QEvent *e);

private:
    Ui::teamsList *ui;
};

#include "_teamslist.cpp"
#endif // _TEAMSLIST_H

_teamslist.cpp:

#include "_teamslist.h"

teamsList::teamsList(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::teamsList)
{
    ui->setupUi(this);
    //this->setWindowTitle(lng.teamsListTitle);
}

teamsList::~teamsList()
{
    delete ui;
}

void teamsList::changeEvent(QEvent *e)
{
    QWidget::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

Teoretycznie idzie to tak (includowanie): main.cpp -> mainwindow.cpp -> _teamslists.h -> _teamslist.cpp
Czyli wszystko jest załadowane...
Zresztą wcześniej też było dobrze: main.cpp -> mainwindow.cpp -> _teamslist.cpp -> _teamslist.h.

0

Aaa, możliwe że chodzi o to, że nie możesz wołać konstruktora domyślnego tej klasy. Sprawdź jak wygląda deklaracja tej klasy i jej konstruktorów w pliku wygenerowanym przez qt.

0
sfdsadfgtfdsfsdfdsfdsf napisał(a)
#include "_teamslist.cpp"

void MainWindow::teamsList()
{
    teamsList tL;
    tL.show();
}

Nazwa tej metody MainWindow jest taka sama jak nazwa klasy którą chcesz w niej utworzyć utworzyć.

1 użytkowników online, w tym zalogowanych: 0, gości: 1