zoukankan      html  css  js  c++  java
  • QT5-控件-QScrollArea-可以用于把一个窗口分割为多个-比如根据图片大小显示滚动条

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <QLabel>
    #include <QPixmap>
    #include <QImage>
    #include <QScrollArea>
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    
    };
    
    #endif // MAINWINDOW_H
    #include "mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
    {
        this->resize(800,600);
        this->centralWidget();
    
        QLabel* label = new QLabel(this);
        QImage image("01.jpg");
        label->setPixmap(QPixmap::fromImage(image));
        QScrollArea* area = new QScrollArea(this);
        area->setWidget(label);
        area->setBackgroundRole(QPalette::Dark);
        area->setGeometry(0,0,image.width()+100,image.height()-60);
    }
    
    MainWindow::~MainWindow()
    {
    
    }
    #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }

  • 相关阅读:
    中文转数字
    半角全角互转
    sql快速查记录数
    杀进程批处理
    线程基本用法
    sql游标用法示例
    BUGFREE的使用
    SQL常用函数
    ASP.NET 2.0 下的验证码控件
    经典sql语句
  • 原文地址:https://www.cnblogs.com/shiyumiao/p/5208428.html
Copyright © 2011-2022 走看看