共 46 篇文章 |
|
QTextEdit向html的转换中。所以第一步需要对待添加的QString进行转化,转化成html支持的文本方式。void stringToHtmlFilter(QString &str)2.根据html标记语言,将QString转化。void stringToHtml(QString &str,QColor crl)str = QString("<span style=\" color:#%1;QString str(" <Hello Qt!>\n");m_Text... 阅3945 转27 评0 公众公开 15-06-04 09:09 |
QListView和QListWidgethttp://blog.csdn.net/leaf6094189/article/details/5803763.QListView是基于Model,而QListWidget是基于Item。MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){QListWidget list;list.setViewMode(QListWidget::IconMode );list.setResizeMode(QListWidget::Adjust); 阅428 转0 评0 公众公开 15-05-22 10:34 |
qt 事件机制什么是自发事件?下面举两个例子:一是posting 事件:QApplication::postEvent(mainWin, new QKeyEvent(QEvent::KeyPress,Key_X,''X'',0));二是sending 事件: QKeyEvent event(QEvent::KeyPress, Key_X, ''X'', 0); QApplication::sendEvent(mainWin, &event);Qt应用程序很少直接调用po... 阅94 转0 评0 公众公开 15-05-21 15:14 |
QComboBox可以随意设置itemData的数值如图所示:需求如下:在组合框QComboBox控件中添加四条学校职员的类型信息。第一条类型信息校长,第二条类型信息是院长,第三条类型信息是老师,第四条类型信息是学生。要获取下拉框的内容可以通过首先获取下拉框的索引currentIndex()然后通过索引找到索引的内容如下:ui->position->itemText(ui->... 阅859 转0 评0 公众公开 15-05-19 15:16 |
qt mysql 分页。最近看到关于qt 中mysql 浏览数据分页,有人用到了qtablewidget 翻页时手动添加。} public: QVariant headerData(int section, Qt::Orientation orientation, int role) const;} QVariant UserSqlTableModel::headerData(int section, Qt::Orientation orient, int role) const { if (orient == Qt::Vertical &&... 阅227 转1 评0 公众公开 15-05-15 14:12 |
boolQDir::mkdir ( constQString &boolQDir::mkpath ( constQString &QString QFileDialog::getOpenFileName ( QWidget * parent = 0, constQString &caption = QString(), constQString &dir = QString(), constQString &QString QFileDialog::getExistingDirectory ( QWidget * parent = 0, constQString &qCopyDire... 阅314 转1 评0 公众公开 15-05-14 16:21 |
buttonGroup->addButton( ui.pushButton1, 1 );buttonGroup->addButton( ui.pushButton2, 2 );buttonGroup->addButton( ui.pushButton3, 3 );buttonGroup->addButton( ui.pushButton4, 4 );buttonGroup->addButton( ui.pushButton5, 5 );buttonGroup->addButton( ui.pushButton6, 6 );buttonGroup->addButton( ui.pushBut... 阅761 转1 评0 公众公开 15-05-14 15:44 |
Cpp代码 QObject *obj = new QTimer; // QTimer inherits QObject QTimer *timer = qobject_cast<QTimer *>(obj); // timer == (QObject *)obj QAbstractButton *button = qobject_cast<QAbstractButton *>(obj); // button == 0. 阅521 转0 评0 公众公开 15-05-14 15:31 |
其原理可简单理解为: QT内部存在一个CSS语法解析器,我们将我们的样式控制以CSS语法定义到外部文件,CSS语法解析器解析后在调用相应的功能模块以完成样式变化。说明:QT Style 样式语法虽然和CSS语法差不多,但是其功能是其子集,在使用QT style时需具备CSS语法知识。Qt样式表单支持所有在CSS2中定义的选择器类型,下面介绍几种最为常用的选择... 阅2896 转6 评0 公众公开 15-05-14 09:57 |
也可以使用:setStyleSheet("text-align:center; font-size:18px; font-weight:bold; font-style:Courier; color:white; ");combo_box->setStyleSheet("QComboBox{border:1px solid gray;}" "QComboBox QAbstractItemView::item{height:25px;}" "QComboBox::down-arrow{image:url(:/icon/arrowdown);}... 阅585 转3 评0 公众公开 15-05-13 16:37 |