简体   繁体   中英

Qt- How to know about visibility of QDialog?

Is there anyway to check visibility of specific QDialog? I tried to check this. Here is my code:

MessageDialog::MessageDialog(QWidget *parent, int Id, QString Name, QPixmap *Photo)
: QDialog(parent),
  m_Id(Id),
  m_Name(Name)
{
    // ...

    if (MessageDialog.isVisible())
        qDebug()<<"visbile";
    else
        qDebug()<<"invisible";        
}

I'm getting an error:

error: expected primary-expression before '.'token if (MessageDialog.isVisible())

The problem is that you are trying to call a non-static function on your MessageDialog class. You should call the isVisible() function on your dialog object, in this case, you should use this or just call isVisible() .

if ( this->isVisible() ) // if ( isVisible() )
    qDebug()<<"visbile";
else
    qDebug()<<"invisible";

But I think it won't be good either, because in the constructor a dialog is not yet visible.

Try removing

MessageDialog. 

ie leaving only

isVisible();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM