Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor symbi4n_programmer's Avatar
    Join Date
    Feb 2009
    Posts
    231
    Hi all,

    I use a QScrollArea in a QWidget view. I add several QWidget´s in the QScrollArea, my example code:

    Code:
    QVBoxLayout* grid;
    grid = new QVBoxLayout(this);
    grid->setAlignment(Qt::AlignTop);
    for (int i(0); i<100; i++)
    {
        QLabel *timeTitleLabel = new QLabel(ui.scrollWidgetContents);
        timeTitleLabel->setText(QString("test%1").arg(QString::number(i)));
        timeTitleLabel->setMinimumHeight(25);
        timeTitleLabel->setMaximumHeight(25);
        timeTitleLabel->setMinimumWidth(180);
        timeTitleLabel->setMaximumWidth(180);
        timeTitleLabel->setAlignment(Qt::AlignCenter);
        grid->addWidget(timeTitleLabel, 0, Qt::AlignLeft);
    }
    ui.scrollWidgetContents->setLayout(grid);
    ui.scrollWidgetContents->adjustSize();
        
    ui.scrollArea->ensureVisible(0, 1000);
    The scroll area it is positioned at initial position instead of at y = 1000. What´s wrong?

    Best regards.

  2. #2
    Regular Contributor Rondo23's Avatar
    Join Date
    Dec 2010
    Posts
    228
    if ur trying to scroll the area to a defined position
    try to use the following
    scrollArea->verticalScrollBar()->setSliderPosition(1000);

    Best Regards,
    Rondo

  3. #3
    Regular Contributor symbi4n_programmer's Avatar
    Join Date
    Feb 2009
    Posts
    231
    It has the same effect.

    What´s wrong?

  4. #4
    Nokia Developer Expert Fuzzbender's Avatar
    Join Date
    Feb 2008
    Posts
    183
    I had sort of similar issue way back. The issue for me was that the scrollbars weren't visible, so they didn't do any scrolling, even if nicely asked. So ensure that your horizontal/vertical scrollbars are visible?

Similar Threads

  1. set Several Widget in QScrollArea
    By mj_124949727@126.com in forum Qt
    Replies: 2
    Last Post: 2010-10-18, 13:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved