Skip to content

Latest commit

 

History

History
160 lines (90 loc) · 4.55 KB

CppQScrollAreaExample1.md

File metadata and controls

160 lines (90 loc) · 4.55 KB

 

 

 

 

 

 

QScrollArea: example 1 is a QScrollArea example.

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

  • Qt Qt: version 4.8.3 (32 bit)
  • STL STL: GNU ISO C++ Library, version 4.7.2

 

 

 

 

 

Qt project file: CppQScrollAreaExample1.pro

 


QT       += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TEMPLATE = app SOURCES += main.cpp\         dialog.cpp HEADERS  += dialog.h FORMS    += dialog.ui

 

 

 

 

 

dialog.h

 


#ifndef DIALOG_H #define DIALOG_H #include <QDialog> namespace Ui {   class Dialog; } class Dialog : public QDialog {   Q_OBJECT    public:   explicit Dialog(QWidget *parent = 0);   ~Dialog();    private:   Ui::Dialog *ui; }; #endif // DIALOG_H

 

 

 

 

 

dialog.cpp

 


#include "dialog.h" #include <QVBoxLayout> #include <QLabel> #include "ui_dialog.h" Dialog::Dialog(QWidget *parent)   : QDialog(parent),   ui(new Ui::Dialog) {   ui->setupUi(this);   QVBoxLayout * const layout = new QVBoxLayout(ui->scrollAreaWidgetContents);   for(int i=0; i!=100; ++i)   {     layout->addWidget(new QLabel(QString::number(i)));   } } Dialog::~Dialog() {   delete ui; }

 

 

 

 

 

main.cpp

 


#include <QApplication> #include "dialog.h" int main(int argc, char *argv[]) {   QApplication a(argc, argv);   Dialog w;   w.show();      return a.exec(); }