#ifndef UI_WINDOW_H
#define UI_WINDOW_H
#include <QtGui>
class Custom_window
: public QWidget{
Q_OBJECT
public:
Custom_window();
private slots:
void new_dialog();
private:
const char *member);
void Button_Layout();
};
#endif
#ifndef UI_WINDOW_H
#define UI_WINDOW_H
#include <QtGui>
class QPushButton;
class QSplitter;
class QGridLayout;
class Custom_window : public QWidget
{
Q_OBJECT
public:
Custom_window();
private slots:
void new_dialog();
private:
QPushButton *createButton(const QString &text,QWidget *receiver,
const char *member);
void Button_Layout();
QLabel *old_window;
QPushButton *start;
QPushButton *stop;
QVBoxLayout *mainLayout;
QHBoxLayout *box;
QGridLayout *buttonsLayout;
QLabel *address;
QLineEdit *url;
QSpacerItem *spacerItem;
QTextEdit *message;
QFile *file;
QPixmap *p;
};
#endif
To copy to clipboard, switch view to plain text mode
window.cpp
#include<QtGui>
#include<stdio.h>
#include "window.h"
Custom_window::Custom_window()
{
old_window->setAlignment(Qt::AlignCenter);
old_window->setText("Press Start");
address->setText("Server I.P");
font.setPointSize(11);
address->setFont(font);
url
->setObjectName
(QString::fromUtf8("url"));
Button_Layout();
mainLayout->addWidget(old_window);
mainLayout->addLayout(buttonsLayout);
mainLayout->addWidget(message);
setLayout(mainLayout);
setWindowTitle(tr("Client GUI"));
resize(640,800);
}
const char *member)
{
button->connect(button,SIGNAL(clicked()),receiver,member);
return button;
}
void Custom_window::Button_Layout()
{
start = createButton(tr("Start"), this, SLOT(new_dialog()));
stop = createButton(tr("Stop"), this, SLOT(close()));
buttonsLayout->addWidget(address,0,0,1,1);
buttonsLayout->addWidget(url,0,1,1,1);
buttonsLayout->addWidget(start,0,2,1,1);
buttonsLayout->addWidget(stop,0,3,1,1);
}
void Custom_window::new_dialog()
{
return;
while (!in.atEnd()) {
url->setText(line);
p=p.scaled ( old_window->width(),old_window->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
old_window->resize(500,480);
old_window->setPixmap(p);
message->append("The path of the file is");
message->append(line);
}
}
#include<QtGui>
#include<stdio.h>
#include "window.h"
Custom_window::Custom_window()
{
old_window = new QLabel;
old_window->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
old_window->setAlignment(Qt::AlignCenter);
old_window->setText("Press Start");
address = new QLabel;
address->setText("Server I.P");
QFont font;
font.setPointSize(11);
address->setFont(font);
url = new QLineEdit;
url->setObjectName(QString::fromUtf8("url"));
message = new QTextEdit;
message->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
Button_Layout();
mainLayout = new QVBoxLayout;
mainLayout->addWidget(old_window);
mainLayout->addLayout(buttonsLayout);
mainLayout->addWidget(message);
setLayout(mainLayout);
setWindowTitle(tr("Client GUI"));
resize(640,800);
}
QPushButton *Custom_window::createButton(const QString &text,QWidget *receiver,
const char *member)
{
QPushButton *button = new QPushButton(text);
button->connect(button,SIGNAL(clicked()),receiver,member);
return button;
}
void Custom_window::Button_Layout()
{
start = createButton(tr("Start"), this, SLOT(new_dialog()));
stop = createButton(tr("Stop"), this, SLOT(close()));
buttonsLayout = new QGridLayout;
buttonsLayout->addWidget(address,0,0,1,1);
buttonsLayout->addWidget(url,0,1,1,1);
buttonsLayout->addWidget(start,0,2,1,1);
buttonsLayout->addWidget(stop,0,3,1,1);
}
void Custom_window::new_dialog()
{
QFile file("in.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text ))
return;
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
url->setText(line);
QPixmap p(line);
p=p.scaled ( old_window->width(),old_window->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
old_window->resize(500,480);
old_window->setPixmap(p);
message->append("The path of the file is");
message->append(line);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks