9 const QString& message,
14 setAttribute ( Qt::WA_DeleteOnClose );
15 setWindowTitle( title );
19 QVBoxLayout*
main =
new QVBoxLayout(
this );
20 main->setContentsMargins( 2, 2, 2, 2 );
21 main->setSpacing ( 2 );
25 textbox->setFrameStyle( QFrame::NoFrame || QFrame::Plain );
28 textbox->setPlainText( message );
33 QDialogButtonBox* btnbox =
new QDialogButtonBox( QDialogButtonBox::Ok );
34 btnbox->setCenterButtons(
true );
35 connect( btnbox, SIGNAL( accepted() ),
39 main->addWidget( btnbox );
45 setWindowTitle( title );
51 textbox->setPlainText( message );
58 textbox->setAcceptRichText(
true );
73 QWidget::adjustSize();
74 QSize wsize = frameSize();
75 QSize tsize =
textbox->frameSize();
76 QSize bsize = wsize - tsize;
78 if ( tsize.width() > wsize.width() || tsize.height() > wsize.height() )
79 bsize = QSize( 4, 32 );
81 QStringList alltext =
textbox->toPlainText().split(
"\n" );
82 int nline = alltext.size();
86 for (
int ii = 0; ii < nline; ii++ )
88 int llen = alltext[ ii ].length();
98 QFontMetrics fm(
textbox->font() );
99 int fontw = fm.width( alltext[ longx ] ) + fm.width(
"WW" );
100 int fonth = fm.lineSpacing() * ( nline + 3 );
101 fontw = ( ( fontw / 20 + 1 ) * 20 );
102 fonth = ( ( fonth / 20 + 1 ) * 20 );
104 tsize = QSize( fontw, fonth );
105 wsize = tsize + bsize;