共 30 篇文章 |
|
在Qt标准FileDialog对话框中插入控件。在QFileDialog定义中可以发现Q_DECLARE_PRIVATE(QFileDialog),这句话就是在QFileDialog中定义了界面的联系。下面代码,在QFileDialog底部加一个Checkbox.CFileDialogWithCheck::CFileDialogWithCheck(QWidget* parent, const QString &caption, const QString &directory, const QString &fi... 阅825 转0 评0 公众公开 16-10-10 16:17 |
QT 中数据转换QString.我自己在编程中遇到的一些数据转换,以后会慢慢积累的。。。。。。。。。。。QString data="1234";quint16 port;port=quint(data.toUint());QString data="helloworld!";QByteArray prodata;prodata.append(data);慢慢收集哦!!!! 阅176 转0 评0 公众公开 16-09-27 14:10 |
protected: bool eventFilter(QObject *obj, QEvent *event);其中几点需要注意的地方:- watchee和watcher必须都是从QObject派生的子类实例- watcher的类必须是一个自定义的子类(因为需要重新实现虚函数, 用现成的类是不行的。)-watcher类的eventFilter函数返回true时表示该事件处理完毕,不再继续传递;返回false表示该事件仍然传递- e... 阅50 转0 评0 公众公开 16-08-17 15:34 |
练习QPainter,运行时看不到图形,只有一个灰色窗口 QPainter::begin: Paint device returned engine == 0, type: 1QPainter::setRenderHint: Painter must be active to set rendering hintsQPainter::setPen: Painter not activeQPainter::setBrush: Painter not active上面就是你的程序运行是的提示。想要使用QPainter画图,就要继... 阅2194 转0 评0 公众公开 16-08-17 11:34 |
QStatusBar类。下面我们在QStatusBar上添加一个QLabel:首先在class的声明中添加一个私有的QLabel属性:private: QAction *openAction; QLabel *msgLabel; 然后在其构造函数中添加: msgLabel = new QLabel; msgLabel->setMinimumSize(msgLabel->sizeHint()); msgLabel->setAlignment(Qt::Ali... 阅875 转1 评0 公众公开 16-08-16 14:17 |
//border-image为程序启动后默认的背景//pressed为按下后的图片//hover为鼠标指向时的按钮图片//当然,还有选中后的图片~这个就自行处理了ui.colorButton->setStyleSheet("QPushButton {border-image:url(pic/border-image.jpg); font-size:24px;} \ QPushButton:hover:pressed {border-image:url(pic/pressed.jpg);font-size:24px;} ... 阅346 转0 评0 公众公开 16-07-27 16:06 |
//设置分界线的样式 QLabel *label = new QLabel(QObject::tr("TestA")); QLabel *label2 = new QLabel(QObject::tr("TestB")); mainSplitter->addWidget(label2); mainSplitter->addWidget(label); mainSplitter->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); ... 阅27 转0 评0 公众公开 16-07-27 16:04 |
头文件: ImageWidget.hpp #ifndef IMAGEWIDGET_HPP #define IMAGEWIDGET_HPP #include <QtCore> #include <QtGui> class ImageWidget : public QWidget {Q_OBJECT public: ImageWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);#endif CPP文件: ImageWidget.cpp #include "ImageWidget.hp... 阅282 转0 评0 公众公开 16-07-11 16:00 |
Qt之Tab键切换焦点顺序简介。pButton1->setStyleSheet("QPushButton:focus{border:none; background: green; color: white;}");pButton2->setStyleSheet("QPushButton:focus{border:none; background: green; color: white;}");pButton3->setStyleSheet("QPushButton:focus{border:none; background: green;... 阅307 转0 评0 公众公开 16-06-28 14:18 |
数码相框实现遍历文件夹图片文件遍历文件夹图片文件。dir.setFilter(QDir::Dirs|QDir::Files);std::cout <<qPrintable(QString("%1 %2%3").arg(fileInfo.size(), 10).arg(fileInfo.fileName(),10).arg(fileInfo.path()))<<endl;filters<<QString("*.jpeg")<<QString("*.jpg")<<QS... 阅144 转1 评0 公众公开 16-04-27 10:23 |