摘要: 方法:创造model类继承QSqlTableModel,然后重载data函数头文件:#ifndef INCOME_MODEL_H#define INCOME_MODEL_H#include <QSqlTableModel>class Income_Model : public QSqlTableModel{public: Income_Model(QObject * parent = 0, QSqlDatabase db = QSqlDatabase()); ~Income_Model(); QVariant data(const QModelIndex &idx, int 阅读全文
posted @ 2013-06-02 11:05 justwake 阅读(7042) 评论(1) 推荐(1) 编辑
摘要: 解决方法如下: 选择:网络->windows 防火墙->高级设置->入站规则 然后点击右上角的新建规则 选择"端口" 下一步,输入3306端口, 阅读全文
posted @ 2013-05-24 09:02 justwake 阅读(754) 评论(0) 推荐(0) 编辑
摘要: 1.设置鼠标到某窗口位置上的时候 QWidget::setCursor(QCursor);2.设置整个窗口的鼠标形状 使用QApplication::setOverrideCursor()进行设置,它会把不同窗口部件中的光标形状全部覆盖掉,直到调用restoreOverrideCursor()。 阅读全文
posted @ 2013-05-17 14:41 justwake 阅读(2417) 评论(0) 推荐(0) 编辑
摘要: 今天使用Qt的QToolBox时,想通过stylesheet改变标签栏的高度:如下:QToolButton::tab{ color:#EEE; border-style:dashed; border-color:white; border-width:2px; font-size:22px; height:33px; line-height:33px;}可是定义高度height:33px;不起作用.通过使用padding也不起作用,高度没有改变。最后是通过在文本中加入'\n'QToolButon->addItem(groupbox,tr("\n#####\n&q 阅读全文
posted @ 2013-05-02 18:47 justwake 阅读(2542) 评论(0) 推荐(0) 编辑
摘要: 转自:http://blog.csdn.net/marlene0312/article/details/5221261boolmouseTracking这个属性保存的是窗口部件跟踪鼠标是否生效。如果鼠标跟踪失效(默认),当鼠标被移动的时候只有在至少一个鼠标按键被按下时,这个窗口部件才会接收鼠标移动事件。如果鼠标跟踪生效,如果没有按键被按下,这个窗口部件也会接收鼠标移动事件。也可以参考mouseMoveEvent()和QApplication::setGlobalMouseTracking()。通过setMouseTracking()设置属性值并且通过hasMouseTracking()来获得属 阅读全文
posted @ 2013-04-19 12:22 justwake 阅读(1750) 评论(0) 推荐(0) 编辑
摘要: 今天按照C++ Gui qt4编程书上介绍的动态加载对话框的时候,自己走进了一个误区:代码:QUiLoader ul;QFile file("a.ui");QWidget * wd = ul.load(&file);if(wd) wd->show();出现如下错误:Designer: An error has occurred while reading the UI file at line 1, column 0: Premature end of document.最后发现自己只是将a.ui文件放到了编译目录,而没有放到可执行文件所在的目录(QtCrea 阅读全文
posted @ 2013-03-22 11:50 justwake 阅读(1360) 评论(0) 推荐(0) 编辑
摘要: Qt下调用windows api方法很简单,包含"windows.h"就好!#include <QApplication>#include "windows.h"#include "stdio.h"#include <QDebug>int main(int argc, char *argv[]){ QApplication a(argc, argv); MEMORYSTATUS mem;//定义一个内存状态变量 DWORD MemTotal,MemFree,VMemTotal,VMemFree;//存储内存状态 阅读全文
posted @ 2013-03-14 13:27 justwake 阅读(11454) 评论(0) 推荐(0) 编辑
摘要: 设置字体大小使用QFont 的setPontSizeQLabel *lb = new QLabel(tr("examp"));QFont ft;ft.setPointSize(14);lb->setFont(ft);设置颜色使用QPaletteQLabel *lb = new QLabel(tr("examp"));QPalette pa;pa.setColor(QPalette::WindowText,Qt::red);lb->setPalette(pa); 阅读全文
posted @ 2013-03-07 17:11 justwake 阅读(27772) 评论(0) 推荐(0) 编辑
摘要: 首先看下QFontDatabase类的说明:The QFontDatabase class provides information about the fonts available in the underlying window system. More...也就是说QFont使用的是系统字体,而不能是自定义字体!所以为了使用自定义字体,必须将自定义字体安装(copy)到系统字体文件夹中(如C:\windows\fonts)./* * 名称:modifyFont * 参数:const QString * 功能:更改本程序所使用的字体 * 返回:bool */bool Monitor::m 阅读全文
posted @ 2013-03-02 12:22 justwake 阅读(2312) 评论(3) 推荐(0) 编辑
摘要: 因需要,需要重绘窗口的标题栏。标题栏通过QWidget实现,可是当使用QPalette设置窗口的背景色后没有效果。代码如下: //QWidget类构造函数内 QPalette p; p.setBrush(this->backgroundRole(),QBrush(QColor(51,51,51))); this->setPalette(p);如果这个QWidget直接show,是有背景色的,但是如果把它放到一个父Widget中时,它就没有了效果。后来通过网上搜索,发现添加如下代码后就可以了: //QWidget类构造函数内 this->setAutoFillB... 阅读全文
posted @ 2013-01-06 12:07 justwake 阅读(11188) 评论(0) 推荐(0) 编辑