QRadioButon vidjeti
#include
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QGroupBox gbx("&Colors");
QRadioButton* pradRed = new QRadioButton("&Red");
QRadioButton* pradGreen = new QRadioButton("&Green"); QRadioButton* pradBlue = new QRadioButton("&Blue"); pradGreen->setChecked(true);
//Layout setup
QVBoxLayout* pvbxLayout = new QVBoxLayout; pvbxLayout->addWidget(pradRed); pvbxLayout->addWidget(pradGreen); pvbxLayout->addWidget(pradBlue); gbx.setLayout(pvbxLayout); gbx.show();
return app.exec(); }
Bu dasturda gbx radio tugmachalari guruhi uchun vidjetlar yaratiladi. PradRed, pradGreen va pradBlue Radiotugmalarini yaratgandan so'ng, ulardan biri (pradGreen) setChecked() usulini true parametr bilan chaqirib yoqilgan holatga o’tkaziladi. Tugmalar gbx guruh vidjetiga joylashtirilgan va QVBoxLayout sinf ob'ekti ularni avtomatik ravishda vertikal ravishda joylashtiradi.
Do'stlaringiz bilan baham: |