Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Refresh a QScrollArea()

[Solved] Refresh a QScrollArea()

Scheduled Pinned Locked Moved General and Desktop
qtscrollareaupdaterefresh
4 Posts 2 Posters 5.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheRacoon
    wrote on last edited by
    #1

    Hi,

    I'm working on a project which needs QScrollArea().

    My problem is that I need to refresh my QScrollArea() but my scrolling widget is in a layout. And this layout in a more global layout.

    I have a violation memory access, the second time I try to update my QScrollArea().

    My guess is that I am doing that refresh wrong ...

    I didn't find any answer in previous posts so if you can help me.

    My code :

       void InitWindowLayout()
       {
    // Layout contenant les indications
    group1 = new QVBoxLayout();
    group1->addWidget(...);
    group1->addWidget(...);
    group2 = new QVBoxLayout();
    group2->addWidget(hand);
    group2->addWidget(....);
    group3 = new QVBoxLayout();
    group3->addWidget(...);
    group3->addWidget(...);
    
    items = new QVBoxLayout();
    items->addSpacerItem(verticalSpacer);
    items->addLayout(group1);
    items->addSpacerItem(verticalSpacer1);
    items->addLayout(group2);
    items->addSpacerItem(verticalSpacer1);
    items->addLayout(group3);
    items->addSpacerItem(verticalSpacer);
    
    group5 = new QHBoxLayout();
    group5->addWidget(...);
    group5->addWidget(...);
    
    scrollArea = new QScrollArea();
    scrollArea->setFixedSize(QSize(640,480));
    
    scrollArea->setStyleSheet("background-color:transparent;");
    scrollArea->setFrameShape(QFrame::NoFrame);
    
    group4 = new QVBoxLayout();
    group4->addLayout(group5);
    group4->setAlignment(group5, Qt::AlignRight);
    group4->addWidget(entrainement);
    group4->addWidget(createLine(255,255,255), NUMBER_OF_COLUMNS_IN_GRID);
    group4->addWidget(scrollArea);
    group4->addSpacerItem(verticalSpacer2);
    
    
    // Layout global avec des marges au-dessus et en-dessous du gridLayout
    globalLayout = new QHBoxLayout();
    globalLayout->addSpacerItem(horizontalSpacer);
    globalLayout->addSpacerItem(verticalSpacer);
    globalLayout->addLayout(items);
    globalLayout->addSpacerItem(horizontalSpacer);
    globalLayout->addLayout(group4);
    globalLayout->addSpacerItem(verticalSpacer);
    globalLayout->addSpacerItem(horizontalSpacer);
    
    // Incorporation du gridLayout dans la fenetre
    setLayout(globalLayout);
      }
    
        void updateScrollArea(){
    
    // Layout contenant les indications
    
    QWidget * dummy = new QWidget();
    dummy->setFixedWidth(620);
    
    QVBoxLayout* data = new QVBoxLayout();
    
    QHBoxLayout*  user = createUserWidget(...);
    
    
    QVBoxLayout*  user_progression = createRecapProgressionWidget(...);
    
    data->addLayout(user );
    data->addSpacerItem(verticalSpacer2);
    data->addLayout(user_progression );
    data->addSpacerItem(verticalSpacer2);
    data->addWidget(createLine(0,0,0), NUMBER_OF_COLUMNS_IN_GRID);
    data->addSpacerItem(verticalSpacer2);
    
    dummy->setLayout(data);
    scrollArea->setWidget(dummy);
    
       }
    

    Have a nice day,

    Racoon

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome,

      Can you post a backtrace of when your application crashes ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TheRacoon
        wrote on last edited by
        #3

        Problem solved by understanding how to put some widgets in a scroll area.

        Only one widget in a scrollarea and then you can put some other widgets in this widget.

        Don't forget to put the widget resizable to true if you want a display.

        Thanks for your help,

        you can put this thread as solved.

        Racoon

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Great !

          You can do that, just update the title prepending [solved] :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved