Results 1 to 2 of 2

Thread: QScrollArea no work properly in QWizardPage object

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QScrollArea no work properly in QWizardPage object

    Hi everyone,
    I'm finding some problems when I try to add a QScrollArea to QWizardPage widget.
    Below is the code:

    //header WizarPage file

    #ifndef SCROLLPAGE_H
    #define SCROLLPAGE_H

    #include <QtGui>
    #include <QWizardPage>

    #define ITEM 20

    class scrollPage: public QWizardPage
    {
    Q_OBJECT

    public:
    scrollPage(QWidget *parent = 0);

    protected:
    void initializePage();

    private:
    QLabel name[ITEM];
    QLabel data[ITEM];
    QPushButton ButInfo[ITEM];
    QHBoxLayout lineH[ITEM];
    };

    #endif // SCROLLPAGE_H

    //WizardPage implementation
    scrollPage::scrollPage(QWidget *parent)
    : QWizardPage(parent)
    {
    setTitle(tr("SCROLL page title"));

    }

    void scrollPage::initializePage()
    {

    int i = 0;
    /* scroll area */
    QScrollArea* sa = new QScrollArea;
    sa->setWidgetResizable(true);

    QScrollBar *scrollBar = sa->verticalScrollBar();
    scrollBar->setSliderDown( true );

    scrollBar->setValue(0);
    sa->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn) ;
    sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysO ff);


    QVBoxLayout * Elenco1 = new QVBoxLayout(sa);

    sa->setLayout(Elenco1);

    while(i< ITEM)
    {
    name[i].setText(tr("NAME"));
    data[i].setText(tr("DATA"));
    ButInfo[i].setText("Info");

    lineH[i].addWidget(&name[i]);
    lineH[i].addWidget(&data[i]);
    lineH[i].addWidget(&ButInfo[i]);

    Elenco1->addLayout(&lineH[i]);
    i++;
    }

    QVBoxLayout * ShowLayout = new QVBoxLayout;
    ShowLayout->addWidget(sa);

    setLayout(ShowLayout);
    }



    When I run the program happens that the page displays a scroll area, but the layout is resized and the page does not scroll.

    Unfortunately they are still a beginner, but if anyone can help I would be very grateful!

    Sincerely,
    Ale

  2. #2
    Join Date
    Jan 2011
    Posts
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QScrollArea no work properly in QWizardPage object

    I discovered the problem.
    I had not considered the fact that QScrollArea use widgets and therefore perform a QScrollArea::SetWidget (widgwet). I modified the code as follows and now works correctly.

    ......
    ........
    scrollBar->setValue(0);
    sa->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn) ;
    sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysO ff);


    QWidget* container = new QWidget(this);
    QVBoxLayout * Elenco1 = new QVBoxLayout(container);
    sa->setWidget(container);


    ......
    ...

    while(i< ITEM)
    {
    ......
    .......
    lineH[i].addWidget(&data[i]);
    lineH[i].addWidget(&ButInfo[i]);
    lineH[i].setSizeConstraint(lineH[i].SetFixedSize);

    Elenco1->addLayout(&lineH[i]);
    i++;
    }
    ......
    ..

Similar Threads

  1. Replies: 7
    Last Post: 8th October 2010, 19:16
  2. QGraphicsView::scale does not work properly.
    By metdos in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2010, 08:58
  3. QT's style sheet does not work properly on Mac OS X
    By sanjayshelke in forum Qt Programming
    Replies: 1
    Last Post: 10th December 2009, 10:50
  4. QLineF::intersect does not work properly (solved)
    By jano_alex_es in forum Newbie
    Replies: 1
    Last Post: 23rd June 2009, 09:06
  5. Why can't I make dynamic_cast work properly?
    By pir in forum General Programming
    Replies: 13
    Last Post: 18th July 2006, 16:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.