Error when using QT Creator.



  • I have a dictionary class for which I have written this header.

    @#ifndef DICTIONARY_H
    #define DICTIONARY_H
    #include <QApplication>
    #include <QString>
    #include <QLabel>
    #include <QWidget>
    #include <QDebug>
    #include <QTextStream>
    #include <QFile>
    #include <QString>
    #include <QStringList>
    #include <QTextStream>
    #include <QTextEdit>
    #include <QDir>
    #include <QHash>
    #include <QMultiMap>
    #include "qstd.h"

    using namespace std;

    class Dictionary
    {
    private:

    static QTextStream screenOut;
    QFile dictFile;
    QFile dataFile;
    QString data;
    QString dataP;
    QStringList dictList;
    QStringList dataList;

    QStringList spellCheckList[];

    QHash<QString, int> dictHash;
    QHash<QString, int> dataHash;
    QHash<QString, int> missSpellHash;
    QMultiMap<int, QString> spellCorrect;
    QMultiMap<int, QString> spellWrong;

    bool isMissSpell(QString word);

    public:
    // Constructor
    Dictionary();

    //Constructor 2
    

    Dictionary(QString filename);

    //Destructor
    ~Dictionary();

    //Function to open text file
    bool open(QString filename);

    bool isAvailable(QString word);

    void spellCheck(QString &message, QString filename);

    void wordCount(int iMost, QString &mostCorrect, QString &mostWrong);

    void setDict(string filename);
    

    };
    #endif@

    I also have this header for my gui main window

    @#ifndef MYDICTIONARYWINDOW_H
    #define MYDICTIONARYWINDOW_H

    #include <QMainWindow>
    #include "src/Dictionary.h"
    #include <string>

    using namespace std;

    namespace Ui {
    class myDictionaryWindow;
    }

    class myDictionaryWindow : public QMainWindow
    {
    Q_OBJECT

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

    public slots:

    void openDictionary(QString filename);
    

    private:
    Ui::myDictionaryWindow *ui;
    Dictionary myDict;
    };

    #endif // MYDICTIONARYWINDOW_H@

    and also my window cpp code:

    @#include "mydictionarywindow.h"
    #include "ui_mydictionarywindow.h"

    myDictionaryWindow::myDictionaryWindow(QWidget parent) :
    QMainWindow(parent),
    ui(new Ui::myDictionaryWindow)
    {
    ui->setupUi(this);
    Dictionary myDict();
    myDict.setDict("American");
    /
    myDict(ui->comboBox->currentText());
    QTextStream QOut(stdout);
    QOut << ui->comboBox->currentText();*/
    //cout << ui->comboBox->currentText();

    }

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

    void myDictionaryWindow::openDictionary(QString filename){
    myDict.open("American");

    }
    @

    I am getting an error however when trying to do myDict.open("American"):
    request for member 'setDict' in 'myDict', which is of non-class type 'Dictionary'

    I still get this error if I declare myDict like this: Dictionary myDict(); or Dictionary myDict("American");



  • Actually scratch that, I just realized the stupid mistake I made.


Log in to reply
 

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