@@ -23,33 +23,54 @@ Dialog::Dialog(QWidget *parent)
2323 m_buttonGroup(new QButtonGroup(this )),
2424 m_okButton(new QPushButton(" OK" , this ))
2525{
26- // Remove or reduce spacing between widgets
27- m_layout->setSpacing (4 ); // smaller space between widgets
28- m_layout->setContentsMargins (10 , 10 , 10 , 10 );
29-
30- // Add stretch to push content to vertical center
31- m_layout->addStretch (1 );
32-
33- // Label (centered)
26+ // ========== Frame to hold content ==========
27+ QFrame *frame = new QFrame (this );
28+ frame->setFrameShape (QFrame::StyledPanel);
29+ frame->setFrameShadow (QFrame::Plain);
30+ frame->setStyleSheet (" QFrame { border: 1px solid #999; border-radius: 6px; padding: 10px; }" );
31+
32+ // Layout inside the frame
33+ QVBoxLayout *frameLayout = new QVBoxLayout (frame);
34+ frameLayout->setSpacing (6 );
35+ frameLayout->setContentsMargins (10 , 10 , 10 , 10 );
36+
37+ // Label
3438 m_label->setAlignment (Qt::AlignCenter);
35- m_layout ->addWidget (m_label, 0 , Qt::AlignHCenter);
39+ frameLayout ->addWidget (m_label, 0 , Qt::AlignHCenter);
3640
37- // Option container (centered and compact)
38- m_optionLayout->setContentsMargins (0 , 0 , 0 , 0 );
41+ // Options
3942 m_optionLayout->setSpacing (4 );
43+ m_optionLayout->setContentsMargins (0 , 0 , 0 , 0 );
4044 m_optionContainer->setLayout (m_optionLayout);
41- m_layout ->addWidget (m_optionContainer, 0 , Qt::AlignHCenter);
45+ frameLayout ->addWidget (m_optionContainer, 0 , Qt::AlignHCenter);
4246
43- // OK Button (centered, fixed width)
47+ // ========== OK + Cancel buttons ==========
48+ QHBoxLayout *buttonLayout = new QHBoxLayout;
4449 m_okButton->setFixedWidth (80 );
45- m_layout->addWidget (m_okButton, 0 , Qt::AlignHCenter);
50+ QPushButton *m_cancelButton = new QPushButton (" Cancel" , this );
51+ m_cancelButton->setFixedWidth (80 );
4652
53+ buttonLayout->addStretch ();
54+ buttonLayout->addWidget (m_okButton);
55+ buttonLayout->addWidget (m_cancelButton);
56+ buttonLayout->addStretch ();
57+
58+ frameLayout->addLayout (buttonLayout);
59+
60+ // ========== Main layout ==========
61+ m_layout->setSpacing (4 );
62+ m_layout->setContentsMargins (10 , 10 , 10 , 10 );
63+ m_layout->addStretch (1 );
64+ m_layout->addWidget (frame, 0 , Qt::AlignHCenter);
4765 m_layout->addStretch (1 );
4866
49- // Connect OK button
67+ // ========== Connections ==========
5068 connect (m_okButton, &QPushButton::clicked, this , [this ]() {
5169 emit okClicked ();
5270 });
71+ connect (m_cancelButton, &QPushButton::clicked, this , [this ]() {
72+ emit cancelClicked (); // Add this signal in your class
73+ });
5374}
5475
5576void Dialog::setMessage (const QString &text) {
0 commit comments