Slots/Signals newbie question

  • Hi I am pretty much a newbie to Qt. I tried searching for an answer to this question but I couldn't find I clear question so I hope you can help me with this.

    Basically I am trying to do a simple login program
    What I have is mainwindow and systemlogin window. A button in mainwindow opens the systemlogin window. In the systemlogin window there is a textfield and a button. When this button is clicked I need to compare the string value in the textfield to a table that is implemented in mainwindow.cpp
    I found out that the best way to do this is by using slots and singals

    Here is the code I have so far


    @#include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "systemlogin.h"
    #include "userlogin.h"
    #include "hashTable.h"
    #include <fstream>
    #include <string>
    #include <QString>
    #include <QFile>
    #include <QTextStream>
    using namespace std;

    string pass = "admin"; //is actually a hashtable but using string for simplicity

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)

    delete ui;

    void MainWindow::on_pushButton_clicked()
    systemlogin systemLogin;

    void MainWindow::on_pushButton_3_clicked()

    bool login (string input)
    if (input == pass)
    return true;
    return false;


    @#include "systemlogin.h"
    #include "ui_systemlogin.h"

    systemlogin::systemlogin(QWidget *parent) :
    ui(new Ui::systemlogin)

    delete ui;

    void systemlogin::on_pushButton_clicked()
    /*Gets a string userinput from the textfield and is supposed to call the login function from mainwindow so it checks

    void systemlogin::on_pushButton_2_clicked()

    I hope my question is not vague
    So how do I go about doing this
    I read that I should add connect to the cpp files. Any pointers on how to do that would be appreciated.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    "This": part of the documentation is what you are looking. You have described there the two possible connection technique (i.e. by hand and automatic)

    Hope it helps

Log in to reply

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