You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
3.3 KiB
128 lines
3.3 KiB
13 years ago
|
|
||
|
BEGIN { print "1..1\n" }
|
||
|
|
||
|
package ButtonsGroups;
|
||
|
use strict;
|
||
13 years ago
|
use TQt;
|
||
|
use TQt::isa qw(TQt::Widget);
|
||
|
use TQt::slots
|
||
13 years ago
|
slotChangeGrp3State => [];
|
||
13 years ago
|
use TQt::attributes qw(
|
||
13 years ago
|
state
|
||
|
rb21
|
||
|
rb22
|
||
|
rb23
|
||
|
);
|
||
|
|
||
|
#
|
||
|
# Constructor
|
||
|
#
|
||
|
# Creates all child widgets of the ButtonGroups window
|
||
|
#
|
||
|
|
||
|
sub NEW {
|
||
|
shift->SUPER::NEW(@_);
|
||
|
|
||
|
# Create Widgets which allow easy layouting
|
||
13 years ago
|
my $vbox = TQt::VBoxLayout(this);
|
||
|
my $box1 = TQt::HBoxLayout($vbox);
|
||
|
my $box2 = TQt::HBoxLayout($vbox);
|
||
13 years ago
|
|
||
|
# ------- first group
|
||
|
|
||
|
# Create an exclusive button group
|
||
13 years ago
|
my $bgrp1 = TQt::ButtonGroup(1, &Horizontal, "Button Group &1 (exclusive)", this);
|
||
13 years ago
|
$box1->addWidget($bgrp1);
|
||
|
$bgrp1->setExclusive(1);
|
||
|
|
||
|
# insert 3 radiobuttons
|
||
13 years ago
|
TQt::RadioButton("R&adiobutton 2", $bgrp1);
|
||
|
TQt::RadioButton("Ra&diobutton 3", $bgrp1);
|
||
13 years ago
|
|
||
|
# ------- second group
|
||
|
|
||
|
# Create a non-exclusive buttongroup
|
||
13 years ago
|
my $bgrp2 = TQt::ButtonGroup(1, &Horizontal, "Button Group &2 (non-exclusive)", this);
|
||
13 years ago
|
$box1->addWidget($bgrp2);
|
||
|
$bgrp2->setExclusive(0);
|
||
|
|
||
|
# insert 3 checkboxes
|
||
13 years ago
|
TQt::CheckBox("&Checkbox 1", $bgrp2);
|
||
|
my $cb12 = TQt::CheckBox("C&heckbox 2", $bgrp2);
|
||
13 years ago
|
$cb12->setChecked(1);
|
||
13 years ago
|
my $cb13 = TQt::CheckBox("Triple &State Button", $bgrp2);
|
||
13 years ago
|
$cb13->setTristate(1);
|
||
|
$cb13->setChecked(1);
|
||
|
|
||
|
# ----------- third group
|
||
|
|
||
|
# create a buttongroup which is exclusive for radiobuttons and non-exclusive for all other buttons
|
||
13 years ago
|
my $bgrp3 = TQt::ButtonGroup(1, &Horizontal, "Button Group &3 (Radiobutton-exclusive)", this);
|
||
13 years ago
|
$box2->addWidget($bgrp3);
|
||
|
$bgrp3->setRadioButtonExclusive(1);
|
||
|
|
||
|
# insert three radiobuttons
|
||
13 years ago
|
rb21 = TQt::RadioButton("Rad&iobutton 1", $bgrp3);
|
||
|
rb22 = TQt::RadioButton("Radi&obutton 2", $bgrp3);
|
||
|
rb23 = TQt::RadioButton("Radio&button 3", $bgrp3);
|
||
13 years ago
|
rb23->setChecked(1);
|
||
|
|
||
|
# insert a checkbox
|
||
13 years ago
|
state = TQt::CheckBox("E&nable Radiobuttons", $bgrp3);
|
||
13 years ago
|
state->setChecked(1);
|
||
13 years ago
|
# ...and connect its TQT_SIGNAL clicked() with the TQT_SLOT slotChangeGrp3State()
|
||
|
this->connect(state, TQT_SIGNAL('clicked()'), TQT_SLOT('slotChangeGrp3State()'));
|
||
13 years ago
|
|
||
|
# ----------- fourth group
|
||
|
|
||
|
# create a groupbox which layouts its childs in a columns
|
||
13 years ago
|
my $bgrp4 = TQt::ButtonGroup(1, &Horizontal, "Groupbox with &normal buttons", this);
|
||
13 years ago
|
$box2->addWidget($bgrp4);
|
||
|
|
||
|
# insert three pushbuttons...
|
||
13 years ago
|
TQt::PushButton("&Push Button", $bgrp4);
|
||
|
my $tb2 = TQt::PushButton("&Toggle Button", $bgrp4);
|
||
|
my $tb3 = TQt::PushButton("&Flat Button", $bgrp4);
|
||
13 years ago
|
|
||
|
# ... and make the second one a toggle button
|
||
|
$tb2->setToggleButton(1);
|
||
|
$tb2->setOn(1);
|
||
|
|
||
|
# ... and make the third one a flat button
|
||
|
$tb3->setFlat(1);
|
||
|
}
|
||
|
|
||
|
#
|
||
13 years ago
|
# TQT_SLOT slotChangeGrp3State()
|
||
13 years ago
|
#
|
||
|
# enables/disables the radiobuttons of the third buttongroup
|
||
|
#
|
||
|
|
||
|
sub slotChangeGrp3State {
|
||
|
rb21->setEnabled(state->isChecked);
|
||
|
rb22->setEnabled(state->isChecked);
|
||
|
rb23->setEnabled(state->isChecked);
|
||
|
}
|
||
|
|
||
|
1;
|
||
|
|
||
|
package main;
|
||
|
|
||
13 years ago
|
use TQt;
|
||
13 years ago
|
use ButtonsGroups;
|
||
|
|
||
13 years ago
|
TQt::StyleFactory::keys(); # disable style plugins (hacky)
|
||
13 years ago
|
|
||
13 years ago
|
my $a = TQt::Application(\@ARGV);
|
||
13 years ago
|
|
||
|
my $buttonsgroups = ButtonsGroups;
|
||
|
$buttonsgroups->resize(500, 250);
|
||
13 years ago
|
$buttonsgroups->setCaption("PerlTQt Test - Please wait");
|
||
13 years ago
|
$a->setMainWidget($buttonsgroups);
|
||
|
$buttonsgroups->show;
|
||
|
|
||
13 years ago
|
TQt::Timer::singleShot( 2000, TQt::app(), TQT_SLOT "quit()" );
|
||
13 years ago
|
my $r = $a->exec;
|
||
|
print +$r?"not ok\n" : "ok 1\n";
|
||
|
exit $r;
|