SirKappe
SirKappe

Reputation: 65

Facing error while returning dialogue box in QT :

I'm trying to return pointer of QMessageBox from one function to another, but i;m facing the below error :

error: 'QMessageBox::QMessageBox(const QMessageBox&)' is private Q_DISABLE_COPY(QMessageBox)

code:

QMessageBox BoxDraw()
{
QMessageBox *msgBox;
bool retValue=false;
msgBox->setWindowTitle("");
QString qstr = QString::fromStdString(MY_String);
QString qyes = QString::fromStdString(MY_String_YES);
QString qno = QString::fromStdString(MY_String_NO);
msgBox->setText(qstr);
msgBox->setParent(0);
msgBox->setWindowFlags(Qt::Window);
msgBox->setWindowFlags(Qt::BypassWindowManagerHint);
return *msgBox;
}

Calling it from another function like :

*global variable* 
QMessageBox *diagBox = NULL;

func A()
{
diagBox = BoxDraw();
}

Upvotes: 0

Views: 40

Answers (1)

user2672107
user2672107

Reputation:

You can't copy a QMessageBox. Return a pointer

QMessageBox* BoxDraw()
{
   QMessageBox *msgBox;
   ...    
   return msgBox;
}

BTW: you are missing a new QMessageBox.

Upvotes: 1

Related Questions