diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-08 12:31:36 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-08 12:31:36 -0600 |
commit | d796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch) | |
tree | 6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/buttongroups/buttongroups.cpp | |
download | tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip |
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/buttongroups/buttongroups.cpp')
-rw-r--r-- | examples/buttongroups/buttongroups.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/examples/buttongroups/buttongroups.cpp b/examples/buttongroups/buttongroups.cpp new file mode 100644 index 000000000..f9859d3e2 --- /dev/null +++ b/examples/buttongroups/buttongroups.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for TQt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#include "buttongroups.h" + +#include <qpopupmenu.h> +#include <qbuttongroup.h> +#include <qlayout.h> +#include <qradiobutton.h> +#include <qcheckbox.h> +#include <qgroupbox.h> +#include <qpushbutton.h> + +/* + * Constructor + * + * Creates all child widgets of the ButtonGroups window + */ + +ButtonsGroups::ButtonsGroups( TQWidget *parent, const char *name ) + : TQWidget( parent, name ) +{ + // Create Widgets which allow easy layouting + TQVBoxLayout *vbox = new TQVBoxLayout( this, 11, 6 ); + TQHBoxLayout *box1 = new TQHBoxLayout( vbox ); + TQHBoxLayout *box2 = new TQHBoxLayout( vbox ); + + // ------- first group + + // Create an exclusive button group + TQButtonGroup *bgrp1 = new TQButtonGroup( 1, TQGroupBox::Horizontal, "Button Group 1 (exclusive)", this); + box1->addWidget( bgrp1 ); + bgrp1->setExclusive( TRUE ); + + // insert 3 radiobuttons + TQRadioButton *rb11 = new TQRadioButton( "&Radiobutton 1", bgrp1 ); + rb11->setChecked( TRUE ); + (void)new TQRadioButton( "R&adiobutton 2", bgrp1 ); + (void)new TQRadioButton( "Ra&diobutton 3", bgrp1 ); + + // ------- second group + + // Create a non-exclusive buttongroup + TQButtonGroup *bgrp2 = new TQButtonGroup( 1, TQGroupBox::Horizontal, "Button Group 2 (non-exclusive)", this ); + box1->addWidget( bgrp2 ); + bgrp2->setExclusive( FALSE ); + + // insert 3 checkboxes + (void)new TQCheckBox( "&Checkbox 1", bgrp2 ); + TQCheckBox *cb12 = new TQCheckBox( "C&heckbox 2", bgrp2 ); + cb12->setChecked( TRUE ); + TQCheckBox *cb13 = new TQCheckBox( "Triple &State Button", bgrp2 ); + cb13->setTristate( TRUE ); + cb13->setChecked( TRUE ); + + // ------------ third group + + // create a buttongroup which is exclusive for radiobuttons and non-exclusive for all other buttons + TQButtonGroup *bgrp3 = new TQButtonGroup( 1, TQGroupBox::Horizontal, "Button Group 3 (Radiobutton-exclusive)", this ); + box2->addWidget( bgrp3 ); + bgrp3->setRadioButtonExclusive( TRUE ); + + // insert three radiobuttons + rb21 = new TQRadioButton( "Rad&iobutton 1", bgrp3 ); + rb22 = new TQRadioButton( "Radi&obutton 2", bgrp3 ); + rb23 = new TQRadioButton( "Radio&button 3", bgrp3 ); + rb23->setChecked( TRUE ); + + // insert a checkbox... + state = new TQCheckBox( "E&nable Radiobuttons", bgrp3 ); + state->setChecked( TRUE ); + // ...and connect its SIGNAL clicked() with the SLOT slotChangeGrp3State() + connect( state, SIGNAL( clicked() ), this, SLOT( slotChangeGrp3State() ) ); + + // ------------ fourth group + + // create a groupbox which layouts its childs in a columns + TQGroupBox *bgrp4 = new TQButtonGroup( 1, TQGroupBox::Horizontal, "Groupbox with normal buttons", this ); + box2->addWidget( bgrp4 ); + + // insert four pushbuttons... + (void)new TQPushButton( "&Push Button", bgrp4, "push" ); + + // now make the second one a toggle button + TQPushButton *tb2 = new TQPushButton( "&Toggle Button", bgrp4, "toggle" ); + tb2->setToggleButton( TRUE ); + tb2->setOn( TRUE ); + + // ... and make the third one a flat button + TQPushButton *tb3 = new TQPushButton( "&Flat Button", bgrp4, "flat" ); + tb3->setFlat(TRUE); + + // .. and the fourth a button with a menu + TQPushButton *tb4 = new TQPushButton( "Popup Button", bgrp4, "popup" ); + TQPopupMenu *menu = new TQPopupMenu(tb4); + menu->insertItem("Item1", 0); + menu->insertItem("Item2", 1); + menu->insertItem("Item3", 2); + menu->insertItem("Item4", 3); + tb4->setPopup(menu); +} + +/* + * SLOT slotChangeGrp3State() + * + * enables/disables the radiobuttons of the third buttongroup + */ + +void ButtonsGroups::slotChangeGrp3State() +{ + rb21->setEnabled( state->isChecked() ); + rb22->setEnabled( state->isChecked() ); + rb23->setEnabled( state->isChecked() ); +} |