Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 2133

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/examples/scrollview/scrollview.doc:4 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Scrollview</title>
<style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Scrollview</h1>

   
<p> 
This example shows how to use Qt's scrollview. This is a widget
optimized for very large contents. 
<p> <hr>
<p> Implementation:
<p> <pre>/****************************************************************************
** $Id:  qt/scrollview.cpp   3.0.2   edited Oct 15 22:12 $
**
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
**
** This file is part of an example program for Qt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

#include &lt;<a href="qscrollview-h.html">qscrollview.h</a>&gt;
#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
#include &lt;<a href="qmenubar-h.html">qmenubar.h</a>&gt;
#include &lt;<a href="qpopupmenu-h.html">qpopupmenu.h</a>&gt;
#include &lt;<a href="qpushbutton-h.html">qpushbutton.h</a>&gt;
#include &lt;<a href="qpainter-h.html">qpainter.h</a>&gt;
#include &lt;<a href="qpixmap-h.html">qpixmap.h</a>&gt;
#include &lt;<a href="qmessagebox-h.html">qmessagebox.h</a>&gt;
#include &lt;<a href="qlayout-h.html">qlayout.h</a>&gt;
#include &lt;<a href="qlabel-h.html">qlabel.h</a>&gt;
#include &lt;<a href="qmultilineedit-h.html">qmultilineedit.h</a>&gt;
#include &lt;<a href="qsizegrip-h.html">qsizegrip.h</a>&gt;
#include &lt;stdlib.h&gt;


static const int style_id       = 0x1000;
static const int lw_id          = 0x2000;
static const int mlw_id         = 0x4000;
static const int mw_id          = 0x8000;
static const int max_lw         = 16;
static const int max_mlw        = 5;
static const int max_mw         = 10;


class BigShrinker : public <a href="qframe.html">QFrame</a> {
    <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
public:
    BigShrinker(QWidget* parent) :
        <a href="qframe.html">QFrame</a>(parent)
    {
        setFrameStyle(QFrame::Box|QFrame::Sunken);
        int h=35;
        int b=0;
        for (int y=0; y&lt;2000-h; y+=h+10) {
            if (y == 0) {
                <a href="qbutton.html">QButton</a>* q=new <a href="qpushbutton.html">QPushButton</a>("Quit", this);
                connect(q, SIGNAL(<a href="qbutton.html#clicked">clicked</a>()), qApp, SLOT(<a href="qapplication.html#quit">quit</a>()));
            } else {
                <a href="qstring.html">QString</a> str;
                if ( b &gt; 0 ) {
<a name="x508"></a>                    str.<a href="qstring.html#sprintf">sprintf</a>("Button %d", b++);
                } else {
                    str = "I'm shrinking!";
                    ++b;
                }
                (new <a href="qpushbutton.html">QPushButton</a>(str, this))-&gt;move(y/2,y);
            }
        }
        resize(1000,2000);

        startTimer(250);
    }

    void timerEvent(QTimerEvent*)
    {
        int w=width();
        int h=height();
        if ( w &gt; 50 ) w -= 1;
        if ( h &gt; 50 ) h -= 2;
        resize(w,h);
    }

    void mouseReleaseEvent(QMouseEvent* e)
    {
        emit clicked(e-&gt;x(), e-&gt;y());
    }

signals:
    void clicked(int,int);
};

class BigMatrix : public <a href="qscrollview.html">QScrollView</a> {
    <a href="qmultilineedit.html">QMultiLineEdit</a> *dragging;
public:
    BigMatrix(QWidget* parent) :
        <a href="qscrollview.html">QScrollView</a>(parent,"matrix", WStaticContents),
        bg("bg.ppm")
    {
<a name="x493"></a>        bg.<a href="qpixmap.html#load">load</a>("bg.ppm");
        resizeContents(400000,300000);

        dragging = 0;
    }

    void viewportMousePressEvent(QMouseEvent* e)
    {
        int x, y;
        viewportToContents( e-&gt;x(),  e-&gt;y(), x, y );
        dragging = new <a href="qmultilineedit.html">QMultiLineEdit</a>(viewport(),"Another");
        dragging-&gt;<a href="qtextedit.html#setText">setText</a>("Thanks!");
        dragging-&gt;<a href="qwidget.html#resize">resize</a>(100,100);
        addChild(dragging, x, y);
        showChild(dragging);
    }

    void viewportMouseReleaseEvent(QMouseEvent*)
    {
        dragging = 0;
    }

    void viewportMouseMoveEvent(QMouseEvent* e)
    {
        if ( dragging ) {
            int mx, my;
            viewportToContents( e-&gt;x(),  e-&gt;y(), mx, my );
            int cx = childX(dragging);
            int cy = childY(dragging);
            int w = mx - cx + 1;
            int h = my - cy + 1;
            <a href="qstring.html">QString</a> msg;
            msg.<a href="qstring.html#sprintf">sprintf</a>("at (%d,%d) %d by %d",cx,cy,w,h);
            dragging-&gt;<a href="qtextedit.html#setText">setText</a>(msg);
            dragging-&gt;<a href="qwidget.html#resize">resize</a>(w,h);
        }
    }

protected:
    void drawContents(QPainter* p, int cx, int cy, int cw, int ch)
    {
        // The Background
<a name="x492"></a>        if ( !bg.<a href="qpixmap.html#isNull">isNull</a>() ) {
<a name="x491"></a>            int rowheight=bg.<a href="qpixmap.html#height">height</a>();
            int toprow=cy/rowheight;
            int bottomrow=(cy+ch+rowheight-1)/rowheight;
<a name="x494"></a>            int colwidth=bg.<a href="qpixmap.html#width">width</a>();
            int leftcol=cx/colwidth;
            int rightcol=(cx+cw+colwidth-1)/colwidth;
            for (int r=toprow; r&lt;=bottomrow; r++) {
                int py=r*rowheight;
                for (int c=leftcol; c&lt;=rightcol; c++) {
                    int px=c*colwidth;
                    p-&gt;drawPixmap(px, py, bg);
                }
            }
        } else {
            p-&gt;fillRect(cx, cy, cw, ch, QColor(240,222,208));
        }

        // The Numbers
        {
            <a href="qfontmetrics.html">QFontMetrics</a> fm=p-&gt;fontMetrics();
<a name="x473"></a>            int rowheight=fm.<a href="qfontmetrics.html#lineSpacing">lineSpacing</a>();
            int toprow=cy/rowheight;
            int bottomrow=(cy+ch+rowheight-1)/rowheight;
<a name="x474"></a>            int colwidth=fm.<a href="qfontmetrics.html#width">width</a>("00000,000000 ")+3;
            int leftcol=cx/colwidth;
            int rightcol=(cx+cw+colwidth-1)/colwidth;
            <a href="qstring.html">QString</a> str;
            for (int r=toprow; r&lt;=bottomrow; r++) {
                int py=r*rowheight;
                for (int c=leftcol; c&lt;=rightcol; c++) {
                    int px=c*colwidth;
                    str.<a href="qstring.html#sprintf">sprintf</a>("%d,%d",c,r);
<a name="x472"></a>                    p-&gt;drawText(px+3, py+fm.<a href="qfontmetrics.html#ascent">ascent</a>(), str);
                }
            }

            // The Big Hint
            if (leftcol&lt;10 &amp;&amp; toprow&lt;5) {
                p-&gt;setFont(QFont("Charter",30));
                p-&gt;setPen(red);
                <a href="qstring.html">QString</a> text;
                text.<a href="qstring.html#sprintf">sprintf</a>("HINT:  Look at %d,%d",215000/colwidth,115000/rowheight);
                p-&gt;drawText(100,50,text);
            }
        }

        // The Big X
        {
            if (cx+cw&gt;200000 &amp;&amp; cy+ch&gt;100000 &amp;&amp; cx&lt;230000 &amp;&amp; cy&lt;130000) {
                // Note that some X server cannot even handle co-ordinates
                // beyond about 4000, so you might not see this.
                p-&gt;drawLine(200000,100000,229999,129999);
                p-&gt;drawLine(229999,100000,200000,129999);

                // X marks the spot!
                p-&gt;setFont(QFont("Charter",100));
                p-&gt;setPen(blue);
                p-&gt;drawText(215000-500,115000-100,1000,200,AlignCenter,"YOU WIN!!!!!");
            }
        }
    }

private:
    <a href="qpixmap.html">QPixmap</a> bg;
};

class ScrollViewExample : public <a href="qwidget.html">QWidget</a> {
    Q_OBJECT

public:
    ScrollViewExample(int technique, QWidget* parent=0, const char* name=0) :
        <a href="qwidget.html">QWidget</a>(parent,name)
    {
        <a href="qmenubar.html">QMenuBar</a>* menubar = new <a href="qmenubar.html">QMenuBar</a>(this);
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( menubar );

        <a href="qpopupmenu.html">QPopupMenu</a>* file = new <a href="qpopupmenu.html">QPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( file );
<a name="x487"></a>        menubar-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;File", file );
        file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Quit", qApp,  SLOT(<a href="qapplication.html#quit">quit</a>()) );

        vp_options = new <a href="qpopupmenu.html">QPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( vp_options );
<a name="x497"></a>        vp_options-&gt;<a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
        menubar-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;ScrollView", vp_options );
<a name="x495"></a>        connect( vp_options, SIGNAL(<a href="qpopupmenu.html#activated">activated</a>(int)),
            this, SLOT(doVPMenuItem(int)) );

        vauto_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Vertical Auto" );
        vaoff_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Vertical AlwaysOff" );
        vaon_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Vertical AlwaysOn" );
<a name="x488"></a>        vp_options-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
        hauto_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Horizontal Auto" );
        haoff_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Horizontal AlwaysOff" );
        haon_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Horizontal AlwaysOn" );
        vp_options-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
        corn_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "cornerWidget" );

        if (technique == 1) {
            vp = new <a href="qscrollview.html">QScrollView</a>(this);
<a name="x507"></a>            BigShrinker *bs = new BigShrinker(0);//(vp-&gt;<a href="qscrollview.html#viewport">viewport</a>());
<a name="x498"></a>            vp-&gt;<a href="qscrollview.html#addChild">addChild</a>(bs);
<a name="x512"></a>            bs-&gt;<a href="qwidget.html#setAcceptDrops">setAcceptDrops</a>(TRUE);
            QObject::<a href="qobject.html#connect">connect</a>(bs, SIGNAL(clicked(int,int)),
<a name="x499"></a>                            vp, SLOT(<a href="qscrollview.html#center">center</a>(int,int)));
        } else {
            vp = new BigMatrix(this);
            if ( technique == 3 )
<a name="x501"></a>                vp-&gt;<a href="qscrollview.html#enableClipper">enableClipper</a>(TRUE);
            srand(1);
            for (int i=0; i&lt;30; i++) {
                <a href="qmultilineedit.html">QMultiLineEdit</a> *l = new <a href="qmultilineedit.html">QMultiLineEdit</a>(vp-&gt;<a href="qscrollview.html#viewport">viewport</a>(),"First");
                l-&gt;<a href="qtextedit.html#setText">setText</a>("Drag out more of these.");
                l-&gt;<a href="qwidget.html#resize">resize</a>(100,100);
                vp-&gt;<a href="qscrollview.html#addChild">addChild</a>(l, rand()%800, rand()%10000);
            }
            vp-&gt;<a href="qscrollview.html#viewport">viewport</a>()-&gt;setBackgroundMode(NoBackground);
        }

        f_options = new <a href="qpopupmenu.html">QPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( f_options );
        f_options-&gt;<a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
        menubar-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "F&amp;rame", f_options );
        connect( f_options, SIGNAL(<a href="qpopupmenu.html#activated">activated</a>(int)),
            this, SLOT(doFMenuItem(int)) );

        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "No Frame", style_id );
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Box", style_id|QFrame::Box );
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Panel", style_id|QFrame::Panel );
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "WinPanel", style_id|QFrame::WinPanel );
        f_options-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Plain", style_id|QFrame::Plain );
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Raised", style_id|QFrame::Raised );
<a name="x486"></a>        f_laststyle = f_options-&gt;<a href="qmenudata.html#indexOf">indexOf</a>(
            f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Sunken", style_id|QFrame::Sunken ));
        f_options-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
        lw_options = new <a href="qpopupmenu.html">QPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( lw_options );
        lw_options-&gt;<a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
        for (int lw = 1; lw &lt;= max_lw; lw++) {
            <a href="qstring.html">QString</a> str;
            str.<a href="qstring.html#sprintf">sprintf</a>("%d Pixels", lw);
            lw_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( str, lw_id | lw );
        }
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Line Width", lw_options );
        connect( lw_options, SIGNAL(<a href="qpopupmenu.html#activated">activated</a>(int)),
            this, SLOT(doFMenuItem(int)) );
        mlw_options = new <a href="qpopupmenu.html">QPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( mlw_options );
        mlw_options-&gt;<a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
        for (int mlw = 0; mlw &lt;= max_mlw; mlw++) {
            <a href="qstring.html">QString</a> str;
            str.<a href="qstring.html#sprintf">sprintf</a>("%d Pixels", mlw);
            mlw_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( str, mlw_id | mlw );
        }
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Midline Width", mlw_options );
        connect( mlw_options, SIGNAL(<a href="qpopupmenu.html#activated">activated</a>(int)),
            this, SLOT(doFMenuItem(int)) );
        mw_options = new <a href="qpopupmenu.html">QPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( mw_options );
        mw_options-&gt;<a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
        for (int mw = 0; mw &lt;= max_mw; mw++) {
            <a href="qstring.html">QString</a> str;
            str.<a href="qstring.html#sprintf">sprintf</a>("%d Pixels", mw);
            mw_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( str, mw_id | mw );
        }
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Margin Width", mw_options );
        connect( mw_options, SIGNAL(<a href="qpopupmenu.html#activated">activated</a>(int)),
            this, SLOT(doFMenuItem(int)) );

        setVPMenuItems();
        setFMenuItems();

        <a href="qvboxlayout.html">QVBoxLayout</a>* vbox = new <a href="qvboxlayout.html">QVBoxLayout</a>(this);
<a name="x484"></a>        vbox-&gt;<a href="qlayout.html#setMenuBar">setMenuBar</a>(menubar);
<a name="x485"></a>        menubar-&gt;<a href="qmenubar.html#setSeparator">setSeparator</a>(QMenuBar::InWindowsStyle);
        vbox-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>(vp);
<a name="x483"></a>        vbox-&gt;<a href="qlayout.html#activate">activate</a>();

        corner = new <a href="qsizegrip.html">QSizeGrip</a>(this);
<a name="x510"></a>        corner-&gt;<a href="qwidget.html#hide">hide</a>();
    }

private slots:
    void doVPMenuItem(int id)
    {
        if (id == vauto_id ) {
<a name="x505"></a>            vp-&gt;<a href="qscrollview.html#setVScrollBarMode">setVScrollBarMode</a>(QScrollView::Auto);
        } else if (id == vaoff_id) {
            vp-&gt;<a href="qscrollview.html#setVScrollBarMode">setVScrollBarMode</a>(QScrollView::AlwaysOff);
        } else if (id == vaon_id) {
            vp-&gt;<a href="qscrollview.html#setVScrollBarMode">setVScrollBarMode</a>(QScrollView::AlwaysOn);
        } else if (id == hauto_id) {
<a name="x504"></a>            vp-&gt;<a href="qscrollview.html#setHScrollBarMode">setHScrollBarMode</a>(QScrollView::Auto);
        } else if (id == haoff_id) {
            vp-&gt;<a href="qscrollview.html#setHScrollBarMode">setHScrollBarMode</a>(QScrollView::AlwaysOff);
        } else if (id == haon_id) {
            vp-&gt;<a href="qscrollview.html#setHScrollBarMode">setHScrollBarMode</a>(QScrollView::AlwaysOn);
        } else if (id == corn_id) {
<a name="x500"></a>            bool corn = !vp-&gt;<a href="qscrollview.html#cornerWidget">cornerWidget</a>();
<a name="x503"></a>            vp-&gt;<a href="qscrollview.html#setCornerWidget">setCornerWidget</a>(corn ? corner : 0);
        } else {
            return; // Not for us to process.
        }
        setVPMenuItems();
    }

    void setVPMenuItems()
    {
<a name="x506"></a>        QScrollView::ScrollBarMode vm = vp-&gt;<a href="qscrollview.html#vScrollBarMode">vScrollBarMode</a>();
<a name="x489"></a>        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( vauto_id, vm == QScrollView::Auto );
        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( vaoff_id, vm == QScrollView::AlwaysOff );
        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( vaon_id, vm == QScrollView::AlwaysOn );

<a name="x502"></a>        QScrollView::ScrollBarMode hm = vp-&gt;<a href="qscrollview.html#hScrollBarMode">hScrollBarMode</a>();
        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( hauto_id, hm == QScrollView::Auto );
        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( haoff_id, hm == QScrollView::AlwaysOff );
        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( haon_id, hm == QScrollView::AlwaysOn );

        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( corn_id, !!vp-&gt;<a href="qscrollview.html#cornerWidget">cornerWidget</a>() );
    }

    void doFMenuItem(int id)
    {
        if (id &amp; style_id) {
            int sty;

            if (id == style_id) {
                sty = 0;
            } else if (id &amp; QFrame::MShape) {
<a name="x475"></a>                sty = vp-&gt;<a href="qframe.html#frameStyle">frameStyle</a>()&amp;QFrame::MShadow;
                sty = (sty ? sty : <a href="qframe.html">QFrame</a>::Plain) | (id&amp;QFrame::MShape);
            } else {
                sty = vp-&gt;<a href="qframe.html#frameStyle">frameStyle</a>()&amp;QFrame::MShape;
                sty = (sty ? sty : <a href="qframe.html">QFrame</a>::Box) | (id&amp;QFrame::MShadow);
            }
<a name="x479"></a>            vp-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>(sty);
        } else if (id &amp; lw_id) {
<a name="x480"></a>            vp-&gt;<a href="qframe.html#setLineWidth">setLineWidth</a>(id&amp;~lw_id);
        } else if (id &amp; mlw_id) {
<a name="x482"></a>            vp-&gt;<a href="qframe.html#setMidLineWidth">setMidLineWidth</a>(id&amp;~mlw_id);
        } else {
<a name="x481"></a>            vp-&gt;<a href="qframe.html#setMargin">setMargin</a>(id&amp;~mw_id);
        }

<a name="x515"></a>        vp-&gt;<a href="qwidget.html#update">update</a>();
        setFMenuItems();
    }

    void setFMenuItems()
    {
        int sty = vp-&gt;<a href="qframe.html#frameStyle">frameStyle</a>();

        f_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( style_id, !sty );

        for (int i=1; i &lt;= f_laststyle; i++) {
<a name="x496"></a>            int id = f_options-&gt;<a href="qpopupmenu.html#idAt">idAt</a>(i);
            if (id &amp; QFrame::MShape)
                f_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( id,
                    ((id&amp;QFrame::MShape) == (sty&amp;QFrame::MShape)) );
            else
                f_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( id,
                    ((id&amp;QFrame::MShadow) == (sty&amp;QFrame::MShadow)) );
        }

        for (int lw=1; lw&lt;=max_lw; lw++)
<a name="x476"></a>            lw_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( lw_id|lw, vp-&gt;<a href="qframe.html#lineWidth">lineWidth</a>() == lw );

        for (int mlw=0; mlw&lt;=max_mlw; mlw++)
<a name="x478"></a>            mlw_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( mlw_id|mlw, vp-&gt;<a href="qframe.html#midLineWidth">midLineWidth</a>() == mlw );

        for (int mw=0; mw&lt;=max_mw; mw++)
<a name="x477"></a>            mw_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( mw_id|mw, vp-&gt;<a href="qframe.html#margin">margin</a>() == mw );
    }

private:
    <a href="qscrollview.html">QScrollView</a>* vp;
    <a href="qpopupmenu.html">QPopupMenu</a>* vp_options;
    <a href="qpopupmenu.html">QPopupMenu</a>* f_options;
    <a href="qpopupmenu.html">QPopupMenu</a>* lw_options;
    <a href="qpopupmenu.html">QPopupMenu</a>* mlw_options;
    <a href="qpopupmenu.html">QPopupMenu</a>* mw_options;
    <a href="qsizegrip.html">QSizeGrip</a>* corner;

    int vauto_id, vaoff_id, vaon_id,
        hauto_id, haoff_id, haon_id,
        corn_id;

    int f_laststyle;
};

int main( int argc, char **argv )
{
    <a href="qapplication.html">QApplication</a> a( argc, argv );

    ScrollViewExample ve1(1,0,"ve1");
    ScrollViewExample ve2(2,0,"ve2");
    ScrollViewExample ve3(3,0,"ve3");
    ve1.<a href="qwidget.html#setCaption">setCaption</a>("Qt Example - Scrollviews");
    ve1.<a href="qwidget.html#show">show</a>();
    ve2.<a href="qwidget.html#setCaption">setCaption</a>("Qt Example - Scrollviews");
    ve2.<a href="qwidget.html#show">show</a>();
    ve3.<a href="qwidget.html#setCaption">setCaption</a>("Qt Example - Scrollviews");
    ve3.<a href="qwidget.html#show">show</a>();

    QObject::<a href="qobject.html#connect">connect</a>(qApp, SIGNAL(<a href="qapplication.html#lastWindowClosed">lastWindowClosed</a>()), qApp, SLOT(<a href="qapplication.html#quit">quit</a>()));

    return a.<a href="qapplication.html#exec">exec</a>();
}

#include "scrollview.moc"
</pre>

<p>See also <a href="examples.html">Examples</a>.

<!-- eof -->
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>