• 15232阅读
  • 6回复

【共享】本人写的一个小程序! [复制链接]

上一主题 下一主题
离线gongyh
 

只看楼主 倒序阅读 楼主  发表于: 2005-09-15
本人写的一个小程序!初学者可以看看!

#ifndef NOTE_H
#define NOTE_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QPushButton>
#include <QtGui/QTextEdit>
#include <QtGui/QWidget>

class note_book:public QWidget
{
  Q_OBJECT
public:
  note_book(QWidget *parent = 0);

public:
  QPushButton *pushButton;
  QPushButton *pushButton_2;
  QTextEdit *textEdit;

public slots:
  void save();
  void dup_view();

};


#endif // NOTE_H


/////////////////////////////////////////////////////////////////

#include "note_book.h"
#include <QString>
#include <QFile>
#include <QTextStream>
#include <QDate>
#include <QTime>

 
  note_book::note_book(QWidget *parent):QWidget(parent)
  {
    this->setEnabled(true);
    //this->resize(QSize(220, 277).expandedTo(this->minimumSizeHint()));
    //this->setGeometry(QRect(10, 250, 75, 23));
    setMinimumSize(220,277);
    setMaximumSize(220,277);

    pushButton = new QPushButton(this);
    pushButton->setObjectName(QString::fromUtf8("pushButton"));
    pushButton->setGeometry(QRect(10, 250, 75, 23));

    pushButton_2 = new QPushButton(this);
    pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
    pushButton_2->setGeometry(QRect(136, 250, 75, 23));

    textEdit = new QTextEdit(this);
    textEdit->setObjectName(QString::fromUtf8("textEdit"));
    textEdit->setGeometry(QRect(10, 10, 201, 221));

    pushButton->setText(QApplication::translate("Form", "Ok"));
    pushButton_2->setText(QApplication::translate("Form", "Cance"));

    QObject::connect(pushButton_2, SIGNAL(clicked()), textEdit, SLOT(clear()));
    QObject::connect(pushButton_2, SIGNAL(clicked()), textEdit, SLOT(setFocus()));
    QObject::connect(pushButton, SIGNAL(clicked()), this, SLOT(save()));


    }

  void note_book::save()
    {
        QDate qdt = QDate::currentDate();
        QTime qdttime = QTime::currentTime();
        const QString str = this->textEdit->toHtml();
        QFile qfile("backup.html");

        if(textEdit->document()->isModified())
        {
        if(qfile.open(QIODevice::Append))
            {
                QTextStream stream(&qfile);

                stream<< qdt.year()<< "--"<<qdt.month()<< "--"<<qdt.day()<<
                      "   ("<<
                      qdttime.hour()<< ":"<<qdttime.minute()<< ":"<<qdttime.second()<<
                      " )"<< str <<endl;

                qfile.close();
            }
          }
        else
        {
          this->textEdit->setHtml("对不起请输入信息!");
          }
    }
[ 此贴被XChinux在2005-09-16 11:04重新编辑 ]
附件: note_gyh.rar (14 K) 下载次数:416
打工不是一辈子的事!
离线17521
只看该作者 1楼 发表于: 2005-09-17
mingwm10.dll 找不到
离线XChinux

只看该作者 2楼 发表于: 2005-09-17
把DevCpp/Bin目录设置到PATH里,或者把它拷贝到可执行目录的下边
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线ediwon
只看该作者 3楼 发表于: 2006-08-17
void suggestion() [slot] // add this slot function
{
    QMessageBox::warning(this, "Ok", "it was write");
}

//
QObject::connect(pushButton, SIGNAL(clicked()), this, SLOT(save()));
QObject::connect(pushButton, SIGNAL(clicked()), this, SLOT(suggestion())); //insert it



And like this, it will be perfect..
BLOG:
http://www.ediwon.com
-------------------------------
离线supfire

只看该作者 4楼 发表于: 2008-03-21
  关心的人还挺多。
离线cling
只看该作者 5楼 发表于: 2009-10-15
支持一下!
只要心中有梦想,就有希望!
离线moonvalley
只看该作者 6楼 发表于: 2010-04-22
谢谢楼主!
快速回复
限100 字节
 
上一个 下一个