我正在開發視頻處理項目。爲了調試,我需要將一些幀的ROI追加到指定寬度的QLabel中。我需要附加子幀的標籤....有任何想法做到這一點?在Qlabel(Qt)中追加圖像
-1
A
回答
0
你可以使用QLayout(horizintal,Vertical e t.c)和QLabel。嘗試根據需要動態創建QLabels,並添加到佈局。有了這個,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盒子;我需要知道它是否可以支持顯示圖像captled並獲得追加和finnaly向下滾動,如果圖像超過維... –
+0
我編輯了答案,我希望它滿足您的需求 –
相關問題
- 1. QLabel QT中的OpenCV圖像座標
- 2. Qt:在QScrollArea內顯示圖像(QLabel)
- 3. 在QLabel中顯示圖像
- 4. 如何在Qt中使用QLabel設置圖像?
- 5. PyQt/Qt:如何在Qlabel小部件中拉伸圖像?
- 6. 在jQuery中追加圖像?
- 7. QT。 QLabel性能
- 8. Qt QLabel click event
- 9. QT顯示圖像與Qlabel在佈局不起作用
- 10. PySide中的QLabel列表/ Qt
- 11. 在QLabel中顯示Dicom圖像/ QGraphicsView
- 12. 如何在QLabel中顯示圖像
- 13. JQuery追加圖像
- 14. 在Qt Creator中,如何在特定類的QLabel上設置背景圖像
- 15. 如何在Qt中繪製QLabel
- 16. 設置一個QLabel的像素圖的Qt框架
- 17. Qt - 使用Widgets和QLabel顯示多個圖像
- 18. QT QLabel(用作圖像容器)全屏錯誤
- 19. QT:使用QPixmap將圖像更新爲QLabel
- 20. 在圖像源中追加URL
- 21. 在wpf中將圖像追加到image.source
- 22. Qt:將圖像放置在一個圓形Qlabel中 - 遮蔽概念?
- 23. 在Qt中爲圖像添加動畫
- 24. 如何在Qt中追加這個?
- 25. Qt的動態QLabel創建
- 26. Qt - 如何在Qt Creator UI Designer中旋轉QLabel
- 27. 追加H2圖像與jquery
- 28. 圖像追加與jQuery
- 29. 刪除Qt中QLabel周圍的邊框
- 30. C++ QT和OpenCV。 QLabel中的setMouseCallBack?
投資回報率?投資回報? –
感興趣的地區 –