QT11 How to set image with QLabel in Qt
2016-03-30 01:38
501 查看
1. drag a label widget on the window, remove the string contained:
2. insert two lines into class login constructor function in login.cpp:
login::login(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::login)
{
ui->setupUi(this);
QPixmap pix("C:/TestQT/QT_SQLite/Tutorial7_How_to_connect_Qt_to_SQLite/Sqlite_DB/icon/panda.png");
ui->label_pic->setPixmap(pix);
mydb = QSqlDatabase::addDatabase("QSQLITE");
mydb.setDatabaseName("C:/work_files/sqlite-tools-win32-x86-3110100/company.db");
if(!mydb.open())
ui->label->setText("Failed to open the database");
else
ui->label->setText("Connected...");
}
3. the running result:
4. the other way to set image with QLabel:
2. insert two lines into class login constructor function in login.cpp:
login::login(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::login)
{
ui->setupUi(this);
QPixmap pix("C:/TestQT/QT_SQLite/Tutorial7_How_to_connect_Qt_to_SQLite/Sqlite_DB/icon/panda.png");
ui->label_pic->setPixmap(pix);
mydb = QSqlDatabase::addDatabase("QSQLITE");
mydb.setDatabaseName("C:/work_files/sqlite-tools-win32-x86-3110100/company.db");
if(!mydb.open())
ui->label->setText("Failed to open the database");
else
ui->label->setText("Connected...");
}
3. the running result:
4. the other way to set image with QLabel:
相关文章推荐
- QT 简单编写贪吃蛇
- QT7 How to connect Qt to SQLite
- Qt提取EXE文件的大图标
- 关于QT5 Failed to find or load platform plugin "windows" 问题
- QT隐藏鼠标
- Qt编译qsqlmysql.dll插件
- qt5.5.1的程序发布方法
- 在Ubuntu 10.04中文版下Qt编程,使用unixODBC和FreeTDS连接MS SQL Server 2005,并且中文不出现乱码的方法
- Qt自定义委托在QTableView中绘制控件、图片、文字(内容比较全)
- 跨平台开发之qt及开源组件qml material
- 分治——sqtx
- QT5读取中文乱码问题
- Qt 写bmp文件
- PyQt5(4)——控件事件响应与信号槽
- GDKOI2016Day2 T2 QT与泰剧 解题报告
- PyQt5应用与实践
- Qt5布局管理(一)——QSplitter分割窗口类
- Qt error : "No Target Architecture"
- QT5 动态链接库的创建和使用
- Qt中配置Winpcap