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. How to connect button to function from other class?
Forum Updated to NodeBB v4.3 + New Features

How to connect button to function from other class?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.4k 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.
  • E Offline
    E Offline
    Essentialfloss7-111XfacF
    wrote on last edited by Essentialfloss7-111XfacF
    #1

    Hi, what am I missing?

    I don't know how to connect function from class Baza to QPushButton in .cpp ui file.
    EncryptFile.h

    class EncryptFile : public QMainWindow
    {
    	Q_OBJECT
    
    public:
    	EncryptFile(QWidget *parent = Q_NULLPTR);
    
    private:
    	Ui::EncryptFileClass ui;
    
    private slots:
    	void run();
    };
    

    Part EncryptFile.cpp

    EncryptFile::EncryptFile(QWidget *parent)
    	: QMainWindow(parent)
    {
    	ui.setupUi(this);
    	Baza *plik = new Baza();
    	connect(ui.createBtn, &QPushButton::clicked, this, &EncryptFile::run);
    	connect(ui.bazaBtn, &QPushButton::clicked, this, &Baza::createDatabase);
    }
    

    Baza.h

    class Baza : public QMainWindow 
    {
    	Q_OBJECT
    private:
    	sqlite3 *database;
    	char *errMsg = 0;
    	int rc;
    public:
    	Baza(QWidget *parent = Q_NULLPTR) {};
    	~Baza() {};
    	
    public slots:
    	void createDatabase();
    };
    

    First connect works. But another connect spit out: E0304, C2664, C3867.

    Any ideas? Thanks :)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Because you are using "this" as target which does not contain the method since it's not the same classe.

      On a side note, Qt has a SQL module so you don't have to use SQLite directly.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • E Offline
        E Offline
        Essentialfloss7-111XfacF
        wrote on last edited by
        #3

        omg. I'm tired.

        Really, big thanks :)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You're welcome !

          Since that answers your question, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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