Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Variable does not name a type?
Forum Updated to NodeBB v4.3 + New Features

Variable does not name a type?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Beatsleigher
    wrote on last edited by
    #1

    Hello, there!

    I'm a complete C++ and Qt n0b, so excuse me if this is a stupid question.

    I'm creating a password storage system, which will (at some point, when I get that far) save passwords in the form of hashes to a file.

    I've created a few variables, but they're giving me the error in the title.

    Here's the code I'm using:

    Header:
    @
    private:
    Ui::MainWindow *ui;
    string fileName;
    QString username;
    ifstream fileStream;
    void readFile();
    void createFile();
    void writeFile();
    @

    MainWindow.cpp:
    @
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <iostream>

    using namespace std;

    QString username = qgetenv("USER");
    string fileName = "/home/" + username + "/.passwordsafe/safe.bin";
    ifstream fileStream(fileName.c_str());

    MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);
    setWindowIcon(QIcon(":/icon/safe.png"));
    setWindowTitle("PasswordSafe by Beatsleigher | Linux Edition");
    this->setFixedSize(this->size());
    if (fileStream.good())
    readFile();
    else
    createFile();
    }

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

    void MainWindow::readFile() {

    }

    void MainWindow::createFile() {

    }

    void MainWindow::writeFile() {

    }

    void MainWindow::on_actionAbout_triggered() {

    }
    @

    Any help with this issue is greatly appreciated. I've searched for a while, found nothing, and this error has been bugging me for over an hour, now.

    Thanks in advance.

    "Nothing is infinite, except human stupidity" - Albert Einstein
    "You shouldn't trust everything you read on the internet" - Abraham Lincoln

    1 Reply Last reply
    0
    • P Offline
      P Offline
      primem0ver
      wrote on last edited by
      #2

      It might help us to have the specific error and the line in which it occurs.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qxoz
        wrote on last edited by
        #3

        And one more thing, better do not mix STL and Qt like that. For writing to file you can use QFile.

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

          By the way, Beatsleigher, Welcome to DevNet :)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved