Advertisement
flyxtop

fortuneclient main.cpp

Jan 8th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  4. ** All rights reserved.
  5. ** Contact: Nokia Corporation (qt-info@nokia.com)
  6. **
  7. ** This file is part of the examples of the Qt Toolkit.
  8. **
  9. ** $QT_BEGIN_LICENSE:LGPL$
  10. ** Commercial Usage
  11. ** Licensees holding valid Qt Commercial licenses may use this file in
  12. ** accordance with the Qt Commercial License Agreement provided with the
  13. ** Software or, alternatively, in accordance with the terms contained in
  14. ** a written agreement between you and Nokia.
  15. **
  16. ** GNU Lesser General Public License Usage
  17. ** Alternatively, this file may be used under the terms of the GNU Lesser
  18. ** General Public License version 2.1 as published by the Free Software
  19. ** Foundation and appearing in the file LICENSE.LGPL included in the
  20. ** packaging of this file. Please review the following information to
  21. ** ensure the GNU Lesser General Public License version 2.1 requirements
  22. ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  23. **
  24. ** In addition, as a special exception, Nokia gives you certain additional
  25. ** rights. These rights are described in the Nokia Qt LGPL Exception
  26. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  27. **
  28. ** GNU General Public License Usage
  29. ** Alternatively, this file may be used under the terms of the GNU
  30. ** General Public License version 3.0 as published by the Free Software
  31. ** Foundation and appearing in the file LICENSE.GPL included in the
  32. ** packaging of this file. Please review the following information to
  33. ** ensure the GNU General Public License version 3.0 requirements will be
  34. ** met: http://www.gnu.org/copyleft/gpl.html.
  35. **
  36. ** If you have questions regarding the use of this file, please contact
  37. ** Nokia at qt-info@nokia.com.
  38. ** $QT_END_LICENSE$
  39. **
  40. ****************************************************************************/
  41.  
  42. #include <QApplication>
  43. #include "client.h"
  44.  
  45. int main(int argc, char *argv[])
  46. {
  47. QApplication app(argc, argv);
  48. Client client;
  49. #ifdef Q_OS_SYMBIAN
  50. // Make application better looking and more usable on small screen
  51. client.showMaximized();
  52. #else
  53. client.show();
  54. #endif
  55. return client.exec();
  56. }
  57.  
  58.  
  59. Here's client.h
  60.  
  61. ** In addition, as a special exception, Nokia gives you certain additional
  62. ** rights. These rights are described in the Nokia Qt LGPL Exception
  63. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  64. **
  65. ** GNU General Public License Usage
  66. ** Alternatively, this file may be used under the terms of the GNU
  67. ** General Public License version 3.0 as published by the Free Software
  68. ** Foundation and appearing in the file LICENSE.GPL included in the
  69. ** packaging of this file. Please review the following information to
  70. ** ensure the GNU General Public License version 3.0 requirements will be
  71. ** met: http://www.gnu.org/copyleft/gpl.html.
  72. **
  73. ** If you have questions regarding the use of this file, please contact
  74. ** Nokia at qt-info@nokia.com.
  75. ** $QT_END_LICENSE$
  76. **
  77. ****************************************************************************/
  78.  
  79. #ifndef CLIENT_H
  80. #define CLIENT_H
  81.  
  82. #include <QDialog>
  83. #include <QTcpSocket>
  84.  
  85. QT_BEGIN_NAMESPACE
  86. class QDialogButtonBox;
  87. class QLabel;
  88. class QLineEdit;
  89. class QPushButton;
  90. class QTcpSocket;
  91. QT_END_NAMESPACE
  92.  
  93. //! [0]
  94. class Client : public QDialog
  95. {
  96. Q_OBJECT
  97.  
  98. public:
  99. Client(QWidget *parent = 0);
  100.  
  101. private slots:
  102. void requestNewFortune();
  103. void readFortune();
  104. void displayError(QAbstractSocket::SocketError socketError);
  105. void enableGetFortuneButton();
  106.  
  107. private:
  108. QLabel *hostLabel;
  109. QLabel *portLabel;
  110. QLineEdit *hostLineEdit;
  111. QLineEdit *portLineEdit;
  112. QLabel *statusLabel;
  113. QPushButton *getFortuneButton;
  114. QPushButton *quitButton;
  115. QDialogButtonBox *buttonBox;
  116.  
  117. QTcpSocket *tcpSocket;
  118. QString currentFortune;
  119. quint16 blockSize;
  120. #ifdef Q_OS_SYMBIAN
  121. bool isDefaultIapSet;
  122. #endif
  123. };
  124. //! [0]
  125.  
  126. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement