zoukankan      html  css  js  c++  java
  • Qt QScrollArea and layout in code

                                Qt QScrollArea and layout in code
    
    
    一、参考文档:
        1. Qt 第六章 QScrollArea类给QWidget添加滚动条
            http://blog.csdn.net/commshare/article/details/6753978
        2. 24小时学会QT编程──窗口的缩放和滚动条的使用 
            http://blog.163.com/vic_kk/blog/static/4947052420083308325238/
        3. QWidget::setLayout: Attempting to set QLayout "" on MainWindow "", which already has a layout
            http://blog.csdn.net/zhuyingqingfen/article/details/6562246
        4. QWidget::setLayout: Attempting to set QLayout "" on MainWindow "", which already has a layout 
            http://yebaoshan.blog.163.com/blog/static/20423116720126267524060/
    
    二、cat main.cpp
        #include "mainwindow.h"
        #include <QApplication>
        #include <QScrollArea>
        
        int main(int argc, char *argv[])
        {
            QApplication a(argc, argv);
        
            MainWindow mainWindow;
        
            // 加入滚动条
            QScrollArea scrollArea;
            scrollArea.setWidget(&mainWindow);
            scrollArea.show();
        
            return a.exec();
        }
    
    三、cat mainwindow.cpp
        #include "mainwindow.h"
        #include <QSize>
        #include <QPushButton>
        #include <QHBoxLayout>
        #include <QTextEdit>
        #include <QWidget>
        
        MainWindow::MainWindow(QWidget *parent)
            : QMainWindow(parent)
        {
            // 设置大小
            this->setMinimumSize(QSize(300, 300));
            this->setMaximumSize(QSize(300, 300));
            // 设置标题
            this->setWindowTitle("About");
        
            QPushButton *button    = new QPushButton("zengjf");
            QTextEdit   *leftEdit  = new QTextEdit(this);
            QTextEdit   *rightEdit = new QTextEdit(this);
        
            QHBoxLayout *layout    = new QHBoxLayout(this);
            layout->addWidget(leftEdit);
            layout->addWidget(button);
            layout->addWidget(rightEdit);
        
            QWidget *widget = new QWidget(this);
            widget->setLayout(layout);
        
            setCentralWidget(widget);
        }
        
        MainWindow::~MainWindow()
        {
        
        }
  • 相关阅读:
    关于J2SE/Jsp/Sping/Hibernate/Struts2的视频下载
    JQuery插件之图片轮播插件–slideBox
    javascript学习-创建json对象数据,遍历
    MD5算法原理
    【Linux】linux经常使用基本命令
    藏书阁(非技术流书籍)
    搭建自己的SIPserver:开源sipserveropensips的搭建及终端TwInkle的使用
    linux下仅仅有rman备份集的异机不同文件夹恢复
    URAL 1684. Jack&#39;s Last Word KMP
    javabean总结
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/4962448.html
Copyright © 2011-2022 走看看