[SOLVED] Class does not name a type



  • Hi, can someone please help to look at this, I'm baffled as I did the same thing for two items and it worked for one but not the other. When I try to compile i get "RadioWindow does not name a type'

    I have a Find window which will call Report and Radio window. It can open the Report window but not the Radio window.

    Findform.h
    @
    #include <QMainWindow>
    #include "radiowindow.h"
    #include "reportwindow.h"

    private:
    Ui::Findform *ui;
    RadioWindow *radiowindow_rf; //error RadioWindows does not name a type
    Reportwindow *report_rf;

    @

    in Findform.cpp
    @
    void Findform::on_actionNew_Ctrl_N_find_triggered()
    {
    radiowindow_rf =new RadioWindow(this);
    radiowindow_rf->setWindowIcon(QIcon(":/icons/radio.ico"));
    radiowindow_rf->setWindowTitle("Radio - User Configuration Manager");
    radiowindow_rf->show();
    }

    void Findform::on_actionReport_triggered()
    {
    report_rf =new Reportwindow(this);
    report_rf->setWindowIcon(QIcon(":/icons/qt-icon80.ico"));
    report_rf->setWindowTitle("Radio - User Configuration Manager");
    report_rf->show();
    }

    @

    I also have a form called radiowindow.h and radiowindow.cpp that calls Find window implemented with the same method, not sure if this would conflict it

    radiowindow.h
    @

    #include "findform.h"
    #include <QMainWindow>

    private:
    Ui::RadioWindow *ui;
    RadioWindow *radiowindow_r;
    Findform *find_r;
    };
    @

    radiowindow.cpp
    @
    RadioWindow::RadioWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::RadioWindow)
    {
    ui->setupUi(this);

    }
    void RadioWindow::on_actionFind_triggered()
    {
    find_r=new Findform(this);
    find_r->setWindowIcon(QIcon(":/icons/qt-icon80.ico"));
    find_r->setWindowTitle("Radio - User Configuration Manager");
    find_r->show();
    find_r->setvalueFind();
    }
    @


  • Moderators

    You have a circural dependency: RadioWindow includes FindForm, and FindForm includes RadioWindow. You need to restructure your code.



  • sierdzio,
    do you have any idea how I should restructure it ? :(
    you see, the problem is, i call those windows via the menu like New (will call Radio Window), Find (will call Find window)


  • Moderators

    Here is a nice summary: "link":http://stackoverflow.com/questions/625799/resolve-circular-dependencies-in-c.

    Or you can delegate opeing of FindWindow to MainWindow, and only emit a signal to do it from RadioWindow.



  • thanks, i will look into it!



  • Thank you sierdzio, the problem has been solved :)


  • Moderators

    I'm happy to haer that. Have fun!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.