有时,模态弹出对话框(QDialog
子类)将自行消失或隐藏&#39 ;;它将继续阻止所有事件到主页面,但将是不可见的,从而迫使程序重新启动。这将在程序的某些运行中发生,而在其他程序中不会发生,看起来是相同的输入。使用调试器,我可以看到程序确实在exec()
函数调用上停止了。但是,由于对话框不可见,因此无法与其进行交互。使用
QDialog( parent, Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint )
和
setModal(true);
我怎样才能弄清楚这里发生了什么?
编辑1:虽然我认为它不会增加太多代码,但需要更多代码:
ModalDialog dialog( this, "Display text" );
dialog.Run(); //Just calls exec()
这真的很简单。但是,调用堆栈可能更具启发性; Hooli.exe!ModalDialog::Run(bool async)
发生两次 - 怎么会发生这种情况?
ntdll.dll!773901fd()未知[下面的框架可能不正确和/或 缺少,没有为ntdll.dll加载的符号]
ntdll.dll!773901fd()未知KernelBase.dll!758e170b()未知 KernelBase.dll!758e1641()未知的user32.dll!74ec77d3()未知 user32.dll!74ed087a()未知Qt5Cored.dll!6659d658()未知 Qt5Widgetsd.dll!64249590()未知 Qt5Widgetsd.dll!6429fe0f()未知Qt5Cored.dll!662b5eed()未知 msvcr110d.dll!_unlock(int locknum)第366行 msvcr110d.dll!_free_dbg(void * pUserData,int nBlockUse)Line 1270 C ++ msvcr110d.dll!_free_dbg(void * pUserData,int nBlockUse) 第1267行C ++ Qt5Cored.dll!66272413()未知 Qt5Widgetsd.dll!64384d57()未知 Qt5Widgetsd.dll!64249590()未知 Qt5Widgetsd.dll!6429fe0f()未知msvcr110d.dll!_unlock(int locknum)第366行C msvcr110d.dll!operator delete(void * pUserData) 第57行C ++ msvcr110d.dll!operator delete(void * pUserData)Line 56 C ++ Qt5Cored.dll!6668b5b5()未知 Qt5Cored.dll!662b5eed()未知Qt5Widgetsd.dll!64384d57()未知 Qt5Widgetsd.dll!64253b6d()未知 Qt5Widgetsd.dll!64251cd5()未知的verifier.dll!10acab48()未知 verifier.dll!10ac9807()未知的verifier.dll!10ac9813()未知 Qt5Cored.dll!662b5eed()未知Qt5Widgetsd.dll!64253b6d()未知 Qt5Widgetsd.dll!64251cd5()未知 Qt5Widgetsd.dll!64249590()未知 Qt5Widgetsd.dll!6429fe0f()未知 Qt5Widgetsd.dll!64249590()未知 Qt5Widgetsd.dll!6429fe0f()未知 Qt5Widgetsd.dll!64262543()未知 Qt5Widgetsd.dll!6429f909()未知 Qt5Widgetsd.dll!6423f6e4()未知 Qt5Widgetsd.dll!6470af14()未知Qt5Cored.dll!6651591b()未知 verifier.dll!10ac98bc()未知KernelBase.dll!758e5500()未知 KernelBase.dll!758e55f3()未知的imm32.dll!755f1db3()未知 imm32.dll!755f1ed8()未知msctf.dll!75346306()未知 msctf.dll!753462ec()未知msctf.dll!7534467c()未知 msctf.dll!753441b5()未知的msctf.dll!753441b5()未知 user32.dll!74ec62fa()未知msctf.dll!753441b5()未知 msctf.dll!753441b5()未知的user32.dll!74ec6d91()未知 user32.dll!74ec6ce9()未知user32.dll!74ec6d91()未知 Qt5Widgetsd.dll!64284b8f()未知的msctf.dll!753441b5()未知 msctf.dll!753441b5()未知的user32.dll!74ecd69b()未知 user32.dll!74ecd762()未知user32.dll!74ecd71e()未知 user32.dll!74ec62fa()未知的user32.dll!74ec6d91()未知 user32.dll!74ec6ce9()未知user32.dll!74ec6d91()未知 user32.dll!74ec966e()未知user32.dll!74ecd70c()未知 verifier.dll!10ac98bc()未知user32.dll!74ec6210()未知 user32.dll!74ec6b34()未知qwindowsd.dll!1971dad1()未知 msctf.dll!753441b5()未知的user32.dll!74ec62fa()未知 user32.dll!74ec6d91()未知的user32.dll!74ec6ce9()未知 user32.dll!74ec6d91()未知的user32.dll!74ec6ce9()未知 user32.dll!74ec966e()未知的user32.dll!74ec96d5()未知 user32.dll!74ecda5b()未知user32.dll!74ec978a()未知 user32.dll!74ecda73()未知的user32.dll!74ecd9bc()未知 user32.dll!74ecadb3()未知user32.dll!74ec62fa()未知 user32.dll!74ec6d91()未知的user32.dll!74ec6ce9()未知 user32.dll!74ec6d91()未知user32.dll!74ec966e()未知 user32.dll!74ecd70c()未知user32.dll!74ec6210()未知 user32.dll!74ec6b34()未知user32.dll!74ec6b00()未知 user32.dll!74ec6b00()未知qwindowsd.dll!1971dad1()未知 user32.dll!74ec6ce9()未知user32.dll!74ec6d91()未知 user32.dll!74ec966e()未知的user32.dll!74ec96d5()未知 Qt5Widgetsd.dll!642a88a6()未知 Qt5Widgetsd.dll!6429f820()未知Qt5Cored.dll!662b5eed()未知 Qt5Cored.dll!662b5eed()未知Qt5Widgetsd.dll!64384d57()未知 Qt5Widgetsd.dll!64253b6d()未知 Qt5Widgetsd.dll!64251cd5()未知 msvcr110d.dll!_heap_alloc_base(unsigned int size)第57 C行 Qt5Widgetsd.dll!64235309()未知 Qt5Widgetsd.dll!64236cb7()未知 Qt5Widgetsd.dll!644f2e63()未知 Qt5Widgetsd.dll!644f0c32()未知的Hooli.exe!ModalDialog :: Run(bool async)第195行C ++ Qt5Cored.dll!6654df39()未知 Qt5Cored.dll!6654d981()未知Qt5Widgetsd.dll!6470d6da()未知 Qt5Widgetsd.dll!643a6df8()未知 Qt5Widgetsd.dll!643a6417()未知 Qt5Widgetsd.dll!643a5852()未知 Qt5Widgetsd.dll!6429f33d()未知 Qt5Widgetsd.dll!643a53b1()未知 Qt5Widgetsd.dll!6446703b()未知 Qt5Widgetsd.dll!64253b5e()未知 Qt5Widgetsd.dll!642505fb()未知Qt5Cored.dll!6650c2e4()未知 user32.dll!74ec8940()未知uxtheme.dll!70196e9f()未知 qwindowsd.dll!197447cc()未知Qt5Cored.dll!6650804c()未知 Qt5Cored.dll!66508252()未知Qt5Widgetsd.dll!644f0c45()未知 Qt5Cored.dll!662bcfbd()未知 Hooli.exe!ModalDialog :: Run(bool async)第195行C ++ Hooli.exe!Hooli :: HomePage :: PerformFileOperation(Hooli :: HomePage :: eFileOperation 操作)第727行C ++ Hooli.exe!Hooli :: HomePage :: onCopy()行 960 C ++ Hooli.exe!Hooli :: HomePage :: qt_static_metacall(QObject * _o, QMetaObject :: Call _c,int _id,void * * _a)第242行C ++
编辑2 :这是ModalDialog的构造函数:
ModalDialog::ModalDialog( QWidget* pParent, const QString& rTitle, const QString& rDescription, eButtonWords words, eModalType type )
: QDialog( pParent, Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint ),
...
{
//We must have a parent to inherit the stylesheet
Q_ASSERT( pParent );
setModal( true );
setAttribute(Qt::WA_TranslucentBackground);
mpDialogBackground = new QWidget( this );
mpDialogBackground->setObjectName( "ModalBackground" );
mpTitle = new QLabel( rTitle, this );
mpTitle->setObjectName( "ModalTitle" );
mpTitle->setWordWrap( true );
mpTitle->setStyleSheet( QString("font: bold %1pt; ").arg(FONT_SIZE) );
switch( type )
{
case ModalType_ACTION_REQUIRED:
{
mpTitle->setProperty( "ModalType", "ActionRequired" );
}
break;
case ModalType_CONFIRM:
{
mpTitle->setProperty( "ModalType", "Confirm" );
}
break;
case ModalType_SUCCESS:
{
mpTitle->setProperty( "ModalType", "Success" );
}
break;
case ModalType_WARNING:
{
mpTitle->setProperty( "ModalType", "Warning" );
}
break;
case ModalType_FAILURE:
{
mpTitle->setProperty( "ModalType", "Failure" );
}
break;
case ModalType_DEFAULT:
default:
//do nothing
break;
}
mpIconLabel = new QLabel( this );
mpDescription = new QLabel( rDescription, this );
mpDescription->setObjectName( "ModalDescription" );
mpDescription->setWordWrap( true );
mpDescription->setStyleSheet( QString("font: %1pt;").arg(FONT_SIZE) );
mpButtonArea = new QWidget( this );
mpButtonArea->setObjectName( "ModalButtonArea" );
mpOkButton = new QPushButton( this );
mpOkButton->resize( DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT );
connect( mpOkButton, SIGNAL( released() ), this, SLOT( OnYesOk() ) );
mpCancelButton = new QPushButton( this );
mpCancelButton->resize( DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT );
connect( mpCancelButton, SIGNAL( released() ), this, SLOT( OnNoCancel() ) );
mpSpecialCancelButton = new QPushButton( this );
mpSpecialCancelButton->resize( DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT );
connect( mpSpecialCancelButton, SIGNAL( released() ), this, SLOT( OnSpecialCancel() ) );
mpSpecialCancelButton->hide();
setPixmapBackground( GuiCommon::cPixmap( ":/mypixmap.png" ), true );
SetButtonStrings( mOkText, mCancelText, mYesText, mNoText );
//The actual widget size is the size of the window because
//a semi-transparent cover is put over the background.
setFixedSize( WIDTH, HEIGHT );
SetSize( DEFAULT_POPUP_WIDTH, DEFAULT_POPUP_HEIGHT );
}