Can no longer build due to no matching function.
-
Don't overwrite the new files with the content of the old one, just cherry-pick the modifications you made e.g. slot added etc.
-
So, recreating your widget from scratch in a new project and just copying the slot code gives you the same error ?
-
So, recreating your widget from scratch in a new project and just copying the slot code gives you the same error ?
-
Did you check that all names were matching ? Ui widget name vs C++ widget name ?
-
@SGaist Right, sorry to be causing so many problems, but thank you for the help! Everything is working now, I missed some of the includes, however I can't use .setModal(true); on a new window opening because it's saying the class has no member called setModal
behindlogin behindlogin; behindlogin.setModal(true); behindlogin.exec(); connClose();
-
You're welcome !
setModal and exec are methods from QDialog. From what I understood you have a QMainWindow, no ?
-
You're welcome !
setModal and exec are methods from QDialog. From what I understood you have a QMainWindow, no ?
-
So problem solved ? :)
-
If you have something like:
{ behindlogin behindlogin; behindlogin.show(); connClose(); } <- behindlogin is destroyed here
-
If you have something like:
{ behindlogin behindlogin; behindlogin.show(); connClose(); } <- behindlogin is destroyed here
-
Is behindlogin a member variable of a class ?
-
@SGaist Right, so I've replaced it with
behindlogin *behindLogin;
in the header file and then
behindLogin =new behindlogin(this); behindLogin->show();
in the main cpp file but it's saying that behindlogin does not name a type?
Hi,
@dejarked said:
in the main cpp file but it's saying that behindlogin does not name a type?
That means you forgot to #include the header that defines the
behindlogin
.@dejarked said:
@SGaist Uh, honestly I'm not sure.. I'm very new to Qt and I've been following tutorials. Everything I've looked at makes it look like this should work but I can't figure out what I'm doing incorrectly.
Is your code exactly the same as what's in the tutorial?
-
Hi,
@dejarked said:
in the main cpp file but it's saying that behindlogin does not name a type?
That means you forgot to #include the header that defines the
behindlogin
.@dejarked said:
@SGaist Uh, honestly I'm not sure.. I'm very new to Qt and I've been following tutorials. Everything I've looked at makes it look like this should work but I can't figure out what I'm doing incorrectly.
Is your code exactly the same as what's in the tutorial?
-
@JKSH Hey, it is exactly the same as it is in the tutorial and the header file was the first thing I checked, behindlogin.h is included in my mainwindow.h which is where I'm trying to declare it.
@dejarked said:
@JKSH Hey, it is exactly the same as it is in the tutorial and the header file was the first thing I checked, behindlogin.h is included in my mainwindow.h which is where I'm trying to declare it.
Can you post:
- The contents of your .pro file
- The contents of behindlogin.h
- The contents of mainwindow.h ?
-
Pro:
# # Project created by QtCreator 2015-03-25T23:10:30 # #------------------------------------------------- QT += core gui sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = project TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp \ behindlogin.cpp \ offlinebehind.cpp \ savingwindow.cpp HEADERS += mainwindow.h \ behindlogin.h \ offlinebehind.h \ savingwindow.h FORMS += mainwindow.ui \ behindlogin.ui \ offlinebehind.ui \ savingwindow.ui
behindlogin.h
#ifndef BEHINDLOGIN_H #define BEHINDLOGIN_H #include <QMainWindow> #include "mainwindow.h" namespace Ui { class behindlogin; } class behindlogin : public QMainWindow { Q_OBJECT public: explicit behindlogin(QWidget *parent = 0); ~behindlogin(); private slots: void on_actionExit_triggered(); void on_actionNew_Data_triggered(); private: Ui::behindlogin *ui; }; #endif // BEHINDLOGIN_H
mainwindow.h:
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include "behindlogin.h" #include <QMainWindow> #include <QtSql> #include <QtDebug> #include <QFileInfo> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: QSqlDatabase mydb; void connClose(){ mydb.close(); mydb.removeDatabase(QSqlDatabase::defaultConnection); } bool connOpen() { mydb=QSqlDatabase::addDatabase("QSQLITE"); mydb.setDatabaseName("C:/Users/Jack/Desktop/ProjNEW/SQlite/dataset.db.sqlite"); if(!mydb.open()){ qDebug()<<("Disconnected.."); return false; } else{ qDebug()<<("Connected.."); return true; } } public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_LoginButton_clicked(); void on_actionOpen_triggered(); void on_actionExit_triggered(); private: Ui::MainWindow *ui; behindlogin *behindLogin; }; #endif // MAINWINDOW_H
-
Hmm... I can't see any mistakes in the code.
What's the full error message? Which line in which file is the error in?
-
Hmm... I can't see any mistakes in the code.
What's the full error message? Which line in which file is the error in?
-
Circular dependencies !
You are including mainwindow.h in behinglogin.h and behindlogin.h in mainwindow.h.
You can remove both includes: in behindlogin.h because you don't use it at all and in mainwindow.h because you can use forward declarations when declaring pointer data members. That also helps avoid including many headers to use your class.