examples/widgets/sliders/slidersgroup.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2004-2006 Trolltech ASA. All rights reserved.
00004 **
00005 ** This file is part of the example classes of the Qt Toolkit.
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://www.trolltech.com/products/qt/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00017 ** sales department at sales@trolltech.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ****************************************************************************/
00023 
00024 #include <QtGui>
00025 
00026 #include "slidersgroup.h"
00027 
00028 SlidersGroup::SlidersGroup(Qt::Orientation orientation, const QString &title,
00029                            QWidget *parent)
00030     : QGroupBox(title, parent)
00031 {
00032     slider = new QSlider(orientation);
00033     slider->setFocusPolicy(Qt::StrongFocus);
00034     slider->setTickPosition(QSlider::TicksBothSides);
00035     slider->setTickInterval(10);
00036     slider->setSingleStep(1);
00037 
00038     scrollBar = new QScrollBar(orientation);
00039     scrollBar->setFocusPolicy(Qt::StrongFocus);
00040 
00041     dial = new QDial;
00042     dial->setFocusPolicy(Qt::StrongFocus);
00043 
00044     connect(slider, SIGNAL(valueChanged(int)), scrollBar, SLOT(setValue(int)));
00045     connect(scrollBar, SIGNAL(valueChanged(int)), dial, SLOT(setValue(int)));
00046     connect(dial, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
00047     connect(dial, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));
00048 
00049     QBoxLayout::Direction direction;
00050 
00051     if (orientation == Qt::Horizontal)
00052         direction = QBoxLayout::TopToBottom;
00053     else
00054         direction = QBoxLayout::LeftToRight;
00055 
00056     QBoxLayout *slidersLayout = new QBoxLayout(direction);
00057     slidersLayout->addWidget(slider);
00058     slidersLayout->addWidget(scrollBar);
00059     slidersLayout->addWidget(dial);
00060     setLayout(slidersLayout);
00061 }
00062 
00063 void SlidersGroup::setValue(int value)
00064 {
00065     slider->setValue(value);
00066 }
00067 
00068 void SlidersGroup::setMinimum(int value)
00069 {
00070     slider->setMinimum(value);
00071     scrollBar->setMinimum(value);
00072     dial->setMinimum(value);
00073 }
00074 
00075 void SlidersGroup::setMaximum(int value)
00076 {
00077     slider->setMaximum(value);
00078     scrollBar->setMaximum(value);
00079     dial->setMaximum(value);
00080 }
00081 
00082 void SlidersGroup::invertAppearance(bool invert)
00083 {
00084     slider->setInvertedAppearance(invert);
00085     scrollBar->setInvertedAppearance(invert);
00086     dial->setInvertedAppearance(invert);
00087 }
00088 
00089 void SlidersGroup::invertKeyBindings(bool invert)
00090 {
00091     slider->setInvertedControls(invert);
00092     scrollBar->setInvertedControls(invert);
00093     dial->setInvertedControls(invert);
00094 }

Generated on Thu Mar 15 11:52:55 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1