私はビデオ処理プロジェクトに取り組んでいます。デバッグのために、指定された幅のQLabelにいくつかのフレームのROIを追加する必要があります。ラベルにサブフレームを追加する必要があります....それを行うためのアイデアはありますか?
1 に答える
0
QLayout(horizintal、Vertical e tc)とQLabelを使用できます。必要に応じてQLabelを動的に作成し、レイアウトに追加してみてください。これで、Uは好きなだけ写真を追加できます...お役に立てば幸いです。
#include <QtGui/QApplication>
#include <QLabel>
#include <QImage>
#include <QLayout>
#include <QMainWindow>
#include <QStringList>
#include <QDebug>
#include <QScrollArea>
//This assumes that the pictures are in the application's Current working directory
//Four pictures used with names 1.png,2.png,3.png and 4.png respectively
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow w;
QWidget *central = new QWidget(&w);
w.setCentralWidget(central);
QLayout *test_layout = new QVBoxLayout(central);
QStringList file_names;
file_names <<"1"<<"2"<<"3"<<"4";
foreach(QString pics, file_names){
QLabel* imagethings = new QLabel();
QImage image(QString("%1.png").arg(pics));//QImage's Constructor takes a file path
imagethings->setPixmap(QPixmap::fromImage(image));
test_layout->addWidget(imagethings);//append the new image
}
// remove Space as a result of widget Margin(see link for Box Model below)
central->setStyleSheet("QLabel{border:0px; margin:0px; padding:0px;}");
central->layout()->setContentsMargins(0,0,0,0);//remove Spac as a result of Layout Margins
//Please try to take advantage of Qt's Detailed Documentatio that Comes with the SDK
w.show();
return a.exec();
}
http://doc.qt.digia.com/qt/stylesheet-customizing.html- ボックスモデル http://doc.qt.digia.com/qt/stylesheet-reference.html- スタイルシートリファレンスリンクから確認できますスタイルシートがよりよく識別できるように
于 2013-01-14T23:51:05.197 に答える