Skip to content

Commit

Permalink
fix(qt_display): fix fps unstable problem, fix the size of BMLabel
Browse files Browse the repository at this point in the history
Change-Id: I51806b9672bb121e7c692b3446d6ebb61eb65ab6
  • Loading branch information
chenx111 authored and yizhou-xu committed Nov 25, 2024
1 parent 9ff32f1 commit a42be1b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 1 addition & 2 deletions element/tools/qt_display/include/BMLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ namespace qt_display {
class BMLabel : public QLabel {
Q_OBJECT
public:
explicit BMLabel(QWidget* parent = nullptr,
Qt::WindowFlags f = Qt::WindowFlags());
explicit BMLabel(QWidget* parent, int width, int height);
~BMLabel();

void show_img(std::shared_ptr<bm_image> bmimg_ptr);
Expand Down
3 changes: 2 additions & 1 deletion element/tools/qt_display/src/BMLabel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace sophon_stream {
namespace element {
namespace qt_display {

BMLabel::BMLabel(QWidget* parent, Qt::WindowFlags f) {
BMLabel::BMLabel(QWidget* parent, int width, int height) :QLabel(parent){
setFixedSize(width, height);
connect(this, &BMLabel::show_signals, this, &BMLabel::show_pixmap);

}
Expand Down
8 changes: 6 additions & 2 deletions element/tools/qt_display/src/qt_display.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,20 @@ int QtDisplay::qt_func() {

qwidget_ptr->setGeometry(0, 0, screen_width, screen_height);
layout = new QGridLayout(qwidget_ptr);
qwidget_ptr->setLayout(layout);

int label_width = screen_width/cols;
int label_height = screen_height/rows;

for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
std::shared_ptr<BMLabel> label_ptr =
std::make_shared<BMLabel>(qwidget_ptr);
std::make_shared<BMLabel>(qwidget_ptr, label_width, label_height);
layout->addWidget(label_ptr.get(), row, col);
label_vec.push_back(label_ptr);
}
}

qwidget_ptr->setLayout(layout);
qwidget_ptr->show();

return qapp->exec();
Expand Down

0 comments on commit a42be1b

Please sign in to comment.