(C++) QtExample11

February 24, 2017 · View on GitHub

 

 

 

 

 

(C++) QtExample11

 

QtQt
CreatorLubuntuUbuntu

 

This Qt example shows how to create a QDialog with QVBoxLayout on the fly, like this screenshot (png).

 

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 5.4.1 (32 bit)
  • STL STL: GNU ISO C++ Library, version 4.9.2

 

 

 

 

 

Qt project file: ./CppQtExample11/CppQtExample11.pro

 


exists(../../DesktopApplication.pri) {   include(../../DesktopApplication.pri) } !exists(../../DesktopApplication.pri) {   QT += core gui   greaterThan(QT_MAJOR_VERSION, 4): QT += widgets   TEMPLATE = app   CONFIG(debug, debug|release) {     message(Debug mode)   }   CONFIG(release, debug|release) {     message(Release mode)     DEFINES += NDEBUG NTRACE_BILDERBIKKEL   }   QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra   unix {     QMAKE_CXXFLAGS += -Werror   } } exists(../../Libraries/Boost.pri) {   include(../../Libraries/Boost.pri) } !exists(../../Libraries/Boost.pri) {   win32 {     INCLUDEPATH += \       ../../../Projects/Libraries/boost_1_55_0   } } SOURCES += main.cpp

 

 

 

 

 

./CppQtExample11/main.cpp

 


#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include <boost/scoped_ptr.hpp> #include <QApplication> #include <QDialog> #include <QPushButton> #include <QVBoxLayout> #pragma GCC diagnostic pop int main(int argc, char *argv[]) {   QApplication a(argc, argv);   boost::scoped_ptr<QDialog> dialog(new QDialog);   boost::scoped_ptr<QVBoxLayout> layout(new QVBoxLayout);   boost::scoped_ptr<QPushButton> button1(new QPushButton);   boost::scoped_ptr<QPushButton> button2(new QPushButton);   //Cannot let button1 do anything fancy,   //without creating a derived class from QDialog   button1->setText("Nothing");   button2->setText("Quit");   button2->connect(button2.get(),SIGNAL(clicked()),dialog.get(),SLOT(close()));   layout->addWidget(button1.get());   layout->addWidget(button2.get());   dialog->setGeometry(0,0,200,100);   dialog->setWindowTitle("CppQtExample11");   dialog->setLayout(layout.get());   dialog->show();   return a.exec(); }