zoukankan      html  css  js  c++  java
  • 【QT源码】系列01

    一,Hello Qt

    #include <QApplication>
    #include <QLabel>
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QLabel *label = new QLabel("Hello Qt!");
        label->show();
        return app.exec();
    }

    二,信号与槽

    #include <QApplication>
    #include <QPushButton>
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QPushButton *button = new QPushButton("Quit");
        QObject::connect(button, SIGNAL(clicked()),
                         &app, SLOT(quit()));
        button->show();
        return app.exec();
    }

    三,SpinBox与Slider的同步

    #include <QApplication>
    #include <QHBoxLayout>
    #include <QSlider>
    #include <QSpinBox>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QWidget *window = new QWidget;
        window->setWindowTitle("Enter Your Age");
    
        QSpinBox *spinBox = new QSpinBox;
        QSlider *slider = new QSlider(Qt::Horizontal);
        spinBox->setRange(0, 130);
        slider->setRange(0, 130);
    
        QObject::connect(spinBox, SIGNAL(valueChanged(int)),
                         slider, SLOT(setValue(int)));
        QObject::connect(slider, SIGNAL(valueChanged(int)),
                         spinBox, SLOT(setValue(int)));
        spinBox->setValue(35);
    
        QHBoxLayout *layout = new QHBoxLayout;
        layout->addWidget(spinBox);
        layout->addWidget(slider);
        window->setLayout(layout);
    
        window->show();
    
        return app.exec();
    }
  • 相关阅读:
    ubuntu: no module named _sqlite
    mysql慢查询分析工具 pt-query-digest
    vue中的时间修饰符stop,self
    面试题 —— Ajax的基本原理总结
    es6笔记 day6-Symbol & generator
    类(class)和继承
    es6笔记 day4---模块化
    es6笔记 day3---Promise
    es6笔记 day3---对象简介语法以及对象新增
    es6笔记 day3---数组新增东西
  • 原文地址:https://www.cnblogs.com/elesos/p/2828795.html
Copyright © 2011-2022 走看看