Wiggly example: Modernize/compactify code
Change-Id: Iacfb308baac8eea60d56bf559113b36acb79d82a Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>bb10
parent
7df4c545ad
commit
82a6d37b99
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
|
|
@ -38,32 +38,26 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QtWidgets>
|
||||
#include <QLineEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "dialog.h"
|
||||
#include "wigglywidget.h"
|
||||
|
||||
//! [0]
|
||||
Dialog::Dialog(QWidget *parent, bool smallScreen)
|
||||
Dialog::Dialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
WigglyWidget *wigglyWidget = new WigglyWidget;
|
||||
QLineEdit *lineEdit = new QLineEdit;
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->addWidget(wigglyWidget);
|
||||
layout->addWidget(lineEdit);
|
||||
setLayout(layout);
|
||||
|
||||
connect(lineEdit, SIGNAL(textChanged(QString)),
|
||||
wigglyWidget, SLOT(setText(QString)));
|
||||
if (!smallScreen){
|
||||
lineEdit->setText(tr("Hello world!"));
|
||||
}
|
||||
else{
|
||||
lineEdit->setText(tr("Hello!"));
|
||||
}
|
||||
connect(lineEdit, &QLineEdit::textChanged, wigglyWidget, &WigglyWidget::setText);
|
||||
lineEdit->setText(tr("Hello world!"));
|
||||
|
||||
setWindowTitle(tr("Wiggly"));
|
||||
resize(360, 145);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
|
|
@ -49,7 +49,7 @@ class Dialog : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Dialog(QWidget *parent = 0, bool smallScreen = false);
|
||||
explicit Dialog(QWidget *parent = 0);
|
||||
};
|
||||
//! [0]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
|
|
@ -45,14 +45,9 @@
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
bool smallScreen = QApplication::arguments().contains("-small-screen");
|
||||
|
||||
Dialog dialog;
|
||||
dialog.show();
|
||||
|
||||
Dialog dialog(0, smallScreen);
|
||||
|
||||
if (!smallScreen)
|
||||
dialog.show();
|
||||
else
|
||||
dialog.showFullScreen();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue