Qt显示图像 linux Qtcreator 树莓派
2017-05-15 11:48
483 查看
mainwindow.h
mainwindow.cpp
ui文件中添加控件ScrollArea,使用默认名字scrollArea。与代码中ui调用所对应。
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QImage> #include <QLabel> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_pushButton_2_clicked(); void on_pushButton_clicked(); private: Ui::MainWindow *ui; QLabel *label; }; #endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QImage image; image.load("lena.jpg"); label = new QLabel(); label->setPixmap(QPixmap::fromImage(image)); label->resize(QSize(image.width(),image.height())); ui->scrollArea->setWidget(label); // ui->labelimage->setPixmap(QPixmap::fromImage(myImage).scaled(ui->labelimage->size())); } MainWindow::~MainWindow() { delete ui; }
ui文件中添加控件ScrollArea,使用默认名字scrollArea。与代码中ui调用所对应。
相关文章推荐
- linux qt中用Qlabel显示图像
- LINUX用QT进行图像显示
- Zedboard & Zynq 图像采集(五) 板端Linux下视频TCP发送 & Linux上位机QT视频显示
- 解决linux下qvfb中QT的中文显示问题
- 在Linux控制台下显示JPEG图像
- Qt打开并显示图像
- Linux的帧缓冲(Frame Buffer)之二:显示图形和图像
- 在Linux控制台下使用libjpeg显示JPEG图像在framebuffer上
- 在Linux控制台下使用libjpeg显示JPEG图像在framebuffer上
- Qt中用QLabel显示OpenCV中Mat图像数据出现扭曲现象的解决
- 嵌入式Linux的图像采集与显示
- 在Linux控制台下显示JPEG图像
- 在Linux控制台下使用libjpeg显示JPEG图像在framebuffer上
- 嵌入式Linux的图像采集与显示
- QT图像类的选择与处理(数码相框优化图片显示)
- Qt中用OpenCV2.4读取并把图像显示在QLabel中 (Ubuntu12.04)
- Qt中图像的显示与基本操作
- 在Linux控制台下使用libjpeg显示JPEG图像在framebuffer上
- 在Linux控制台下显示JPEG图像
- Qt中图像的显示与基本操作