質問

I have this code:

  QFrame* contentsFrame = new QFrame();
  contentsFrame->setLayout(contentsLyt_);

  QScrollArea* scrollArea = new QScrollArea();
  scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
  scrollArea->setWidgetResizable(false);
  contentsLyt_->addWidget( scrollArea );

  scrollArea->setWidget(contentsFrame);

The app gets freezed while setting the widget. I cannot debug or enter to setWidget because it is Qt functionality. Executing this freezes. Stopping there doesn't give me any clue. Both pointers are not NULL. It is some kind of loop inside Qt i don't understand.

Any idea?

役に立ちましたか?

解決

You are setting a widget for the scroll area which indirectly contains the scroll area. That's why Qt is getting into an infinite loop, I think.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top