Hi,
Thank You So much for your reply....
"In general if you store the slide_ID in a member of the class it should still be there when you access it in Clinical_savetodb(). At least if you use the same instance of the class. Please show the code where you call getSlideID() and Clinical_savetodb().
By the way, your naming scheme is a bit confusing. Normally what you called getSlideID would be called setSlideID, because you set the value inside the class. A get function would return that value."
Actually what I'm doing is : I have 4 different classes.
I will show my code
Added after 24 minutes:
personal.h
class Personal : public QWidget
{
Q_OBJECT
public: explicit Personal(QWidget *parent = nullptr);
private:
void create_personal_details_groupbox();
public slots:
void savetodb();
void gettext();
signals:
void pass_SlideID(QString slideid); // My signal containing value to be passed from personal to clinical
}
personal.cpp
Personal::Personal(QWidget *parent) : QWidget(parent)
{
// All other stuffs
Clinical *clinical = new Clinical();
connect(this, SIGNAL(pass_SlideID(QString)),clinical, SLOT(getSlideID(QString)));
}
void Personal::savetodb()
{
QString cytono_val = this->cytologyvalue->text();
// All other stuf......
if (query.exec())
{
QMessageBox::critical(this, tr("Save"),tr("Saved Successfully..."));
emit pass_SlideID(cytono_val); //------------ here i emits the value of my slideid-----//
}
else
{
QMessageBox::critical(this,tr("Database error"),tr("Could not setup database"));
}
}
From the above class when push button "Save " clicks "savetodb()" would emit the value of Slide ID to the slot of Clinical class having slot "getSlideID(QString)"
Clinical.h
class Clinical : public QWidget
{
Q_OBJECT
public:
explicit Clinical(QWidget *parent = nullptr);
QString slide_idValue;
private:
public slots:
void getSlideID(QString slide_ID); // function where slide id getting
void Clinical_savetodb(); // function where i again want the slide id for further databse operations
signals:
}
Clinical.cpp
Clinical::Clinical(QWidget *parent) : QWidget(parent)
{
// All Other Stuff---
void Clinical::getSlideID(QString slide_ID){
slide_idValue = slide_ID;
qDebug()<<"Expected Value is ::"<<slide_idValue;
}
void Clinical::Clinical_savetodb()
{
qDebug()<<"Expected Value is ::"<<slide_idValue;
//----uses the slide if for Other DB Operations----
}
}
I need to get the value of slide id inside both the functions getSlideID(QString slide_ID) and Clinical_savetodb()





Reply With Quote

Bookmarks