2013-01-13 3 views
-1

저는 비디오 프로세싱 프로젝트를 진행하고 있습니다. 디버깅을 위해 특정 폭의 QLabel에 일부 프레임의 ROI를 추가해야합니다. 라벨에 서브 프레임을 추가해야합니다 .... 그 일을위한 아이디어가 있습니까 ??Qlabel (Qt)에 이미지 추가

+2

투자 수익 (ROI)을 분별하는 당신은 링크를 통해 확인 할 수 있습니까? 투자 수익? –

+0

관심 영역 –

답변

0

QLayout (horizintal, Vertical e t.c) 및 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 -box 모델 http://doc.qt.digia.com/qt/stylesheet-reference.html -Stylesheet 참조 스타일 시트 더 나은

+0

사실 Qlabel 상자를 만들었습니다. 나는 이미지가 caputured를 보여주는 것을 지원할 수 있는지 알아야하고 이미지가 치수를 초과하면 아래쪽으로 추가되고 finnaly 스크롤됩니다. –

+0

나는 대답을 편집 했으므로, 그것이 당신의 요구에 부합되기를 바랍니다. –