• 大小: 879KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-06
  • 语言: C/C++
  • 标签: C++  QT  GUI设计  

资源简介

对于学习QT4.x系列的朋友们,《C++ GUI QT编程(第二版)》是最经典不过的书籍之一了,附件为原书配套示例源码。

资源截图

代码片段和文件信息

import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;

public class FindDialog extends QDialog {
    public Signal2 findNext =
            new Signal2();

    public Signal2 findPrevious =
            new Signal2();

    public FindDialog(QWidget parent) {
        super(parent);

        label = new QLabel(tr(“Find &what:“));
        lineEdit = new QLineEdit();
        label.setBuddy(lineEdit);

        caseCheckBox = new QCheckBox(tr(“Match &case“));
        backwardCheckBox = new QCheckBox(tr(“Search &backward“));

        findButton = new QPushButton(tr(“&Find“));
        findButton.setDefault(true);
        findButton.setEnabled(false);

        closeButton = new QPushButton(tr(“Close“));

        lineEdit.textChanged.connect(this “enableFindButton(String)“);
        findButton.clicked.connect(this “findClicked()“);
        closeButton.clicked.connect(this “reject()“);

        QHBoxLayout topLeftLayout = new QHBoxLayout();
        topLeftLayout.addWidget(label);
        topLeftLayout.addWidget(lineEdit);

        QVBoxLayout leftLayout = new QVBoxLayout();
        leftLayout.addLayout(topLeftLayout);
        leftLayout.addWidget(caseCheckBox);
        leftLayout.addWidget(backwardCheckBox);

        QVBoxLayout rightLayout = new QVBoxLayout();
        rightLayout.addWidget(findButton);
        rightLayout.addWidget(closeButton);
        rightLayout.addStretch();

        QHBoxLayout mainLayout = new QHBoxLayout();
        mainLayout.addLayout(leftLayout);
        mainLayout.addLayout(rightLayout);
        setLayout(mainLayout);

        setWindowtitle(tr(“Jambi Find“));
        setFixedHeight(sizeHint().height());
    }

    private void findClicked() {
        String text = lineEdit.text();
        Qt.CaseSensitivity cs = caseCheckBox.isChecked()
                ? Qt.CaseSensitivity.CaseSensitive
                : Qt.CaseSensitivity.CaseInsensitive;
        if (backwardCheckBox.isChecked()) {
            findPrevious.emit(text cs);
        } else {
            findNext.emit(text cs);
        }
    }

    private void enableFindButton(String text) {
        findButton.setEnabled(text.length() == 0);
    }

    private QLabel label;
    private QLineEdit lineEdit;
    private QCheckBox caseCheckBox;
    private QCheckBox backwardCheckBox;
    private QPushButton findButton;
    private QPushButton closeButton;

    public static void main(String[] args) {
        QApplication.initialize(args);
        FindDialog dialog = new FindDialog(null);
        dialog.show();
        QApplication.exec();
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2008-01-09 08:43  qt-book\
     目录           0  2008-01-09 08:43  qt-book\appendixC\
     目录           0  2008-01-09 08:43  qt-book\appendixC\jambiplotter2\
     文件        1101  2008-01-09 08:43  qt-book\appendixC\jambiplotter2\JambiPlotter.java
     文件         500  2008-01-09 08:43  qt-book\appendixC\jambiplotter2\jambiplotter.pro
     文件          50  2008-01-09 08:43  qt-book\appendixC\jambiplotter2\jambiplotter.h
     文件         898  2008-01-09 08:43  qt-book\appendixC\jambiplotter2\jambiplotter.xml
     目录           0  2008-01-09 08:43  qt-book\appendixC\jambigotocell\
     文件         910  2008-01-09 08:43  qt-book\appendixC\jambigotocell\GoToCellDialog.java
     文件        2306  2008-01-09 08:43  qt-book\appendixC\jambigotocell\GoToCellDialog.jui
     目录           0  2008-01-09 08:43  qt-book\appendixC\plotter\
     目录           0  2008-01-09 08:43  qt-book\appendixC\plotter\images\
     文件         936  2008-01-09 08:43  qt-book\appendixC\plotter\images\zoomin.png
     文件         955  2008-01-09 08:43  qt-book\appendixC\plotter\images\zoomout.png
     文件         134  2008-01-09 08:43  qt-book\appendixC\plotter\plotter.qrc
     文件      759528  2008-01-09 08:43  qt-book\appendixC\plotter\in1.txt
     文件         129  2008-01-09 08:43  qt-book\appendixC\plotter\plotter.pro
     文件        1634  2008-01-09 08:43  qt-book\appendixC\plotter\plotter.h
     文件        9747  2008-01-09 08:43  qt-book\appendixC\plotter\plotter.cpp
     目录           0  2008-01-09 08:43  qt-book\appendixC\jambifind\
     文件        2677  2008-01-09 08:43  qt-book\appendixC\jambifind\FindDialog.java
     目录           0  2008-01-09 08:43  qt-book\appendixC\jambiplotter1\
     文件        1121  2008-01-09 08:43  qt-book\appendixC\jambiplotter1\JambiPlotter.java
     文件         515  2008-01-09 08:43  qt-book\appendixC\jambiplotter1\jambiplotter.pro
     文件          50  2008-01-09 08:43  qt-book\appendixC\jambiplotter1\jambiplotter.h
     文件         400  2008-01-09 08:43  qt-book\appendixC\jambiplotter1\jambiplotter.xml
     目录           0  2008-01-09 08:43  qt-book\chap23\
     目录           0  2008-01-09 08:43  qt-book\chap23\bouncer\
     文件        1335  2008-01-09 08:43  qt-book\chap23\bouncer\demo.html
     文件         270  2008-01-09 08:43  qt-book\chap23\bouncer\bouncer.pro
     文件         832  2008-01-09 08:43  qt-book\chap23\bouncer\objectsafetyimpl.cpp
............此处省略612个文件信息

评论

共有 条评论