I've declared a qpointer to a QLineEdit pointer called txtNewCareer in the class Populate. I have created a getter function in Populate so other classes can access that pointer. It is a dynamically created pointer that creates a QLineEdit, which I need to keep as dynamic and on the heap.
So, how do I appropriately call my getter function return_txtNewCareer()? I've had not problems returning regular pointers. But I am just learning how to use QPointers.
As you can see I'm trying to connect a signal of the QPointer txtNewCareer by calling the return_txtNewCareer function of class Populate, to a slot in mainwindow class.
Thanks.
This is a skeleton of my classes with the basic information of what I'm doing.
Populate.h
#include <QPointer>
#include <QPointer>
To copy to clipboard, switch view to plain text mode
public:
public:
QLineEdit* return_txtNewCareer();
To copy to clipboard, switch view to plain text mode
private:
QPionter<QLineEdit> txtNewCareer;
private:
QPionter<QLineEdit> txtNewCareer;
To copy to clipboard, switch view to plain text mode
Populate.cpp
QPointer<QLineEdit> txtNewCareer
= new QLineEdit
QPointer<QLineEdit> txtNewCareer = new QLineEdit
To copy to clipboard, switch view to plain text mode
return txtNewCareer;
}
QLineEdit* Populate::return_txtNewCareer(){
return txtNewCareer;
}
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
connect(populate
->return_txtNewCareer
(),
SIGNAL(textEdited
(QString)),
this,
SLOT(txtNewCareer_edited
(QString)));
connect(populate->return_txtNewCareer(), SIGNAL(textEdited(QString)), this, SLOT(txtNewCareer_edited(QString)));
To copy to clipboard, switch view to plain text mode
I am unable to get the program to run. I have narrowed down the problem to the connect statement because I have commented it out and the program runs. When I run the program with the connect statement I get this Segmentation fault:
Signal name : SIGSEGV
Signal meaning : Segmentation fault
Bookmarks