`
ydbc
  • 浏览: 766757 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论
文章列表
QButtonGroup的简单应用 所有代码都是在qt3.3.8+fedora8下运行的。 QButtonGroup用于统一管理一组QButton按钮。理论上所有继承自QButton的按钮类都可以使用。这里以QPushButton和QRadioButton为例演示。按钮分组的作用主要用在项目选择上,可以单选,也可以多选,根据属性设置而定。 头文件: <qbuttongroup.h> 主要属性和函数:int id:按钮的标签,可以用这个标签来获得或操作组里的各个按钮。 bool exclusive:This property holds whether the ...
mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" #include "QDebug" #include "QCheckBox" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->tableWidget ...
在QTableWidget中会经常用的checkBox,但是如何判断复选框是否被选中呢,方法是利用QTableWidget::cellChanged()函数,检查单元格内容的变化,然后连接此信号,在槽函数中检测checkBox的状态,代码如下: 查看源代码 打印帮助 ...
这篇文章是在Blogspot上看到的一篇文章,能够解决QString, wchar_t *, TCHAR和其他字符或字符串类型之间的转换,方便在使用Windows API的时候转换的麻烦。 原文地址:http://tkrotoff.blogspot.com/2010/04/code-snippets-about-qstring-wchart.html 1 //QString to wchar_t *: 2 const wchar_t * encodedName = reinterpret_cast<const wchar_t *>(file ...
QWizard下一步按钮的控制 QWizard是Qt的向导类,在向导过程中,可以通过函数registerField注册字段实现全局访问,而且可以通过4种方法来控制下一步或者完成按钮的可用性:第一种方法,isComplete函数,其应用于QWizardPage,可控制单个向导页面的“下一步”或者“完成”按钮的可用性,函数如下: 1 bool QWizardPage::isComplete () const[virtual] 下面是isComplete的实现,源码来源于 http://doc.qt.nokia.com/qq/qq22-qwizard.h ...
Qt下的模态和非模态对话框 模态对话框(Modal Dialog)与非模态对话框(Modeless Dialog)的概念不是Qt所独有的,在各种不同的平台下都存在。又有叫法是称为模式对话框,无模式对话框等。 所谓模态对话框就是在其没有被关闭之前,用户不能与同一个应用程序的其他窗口进行交互,直到该对话框关闭。对于非模态对话框,当被打开时,用户既可选择和 该对话框进行交互,也可以选择同应用程序的其他窗口交互。 在Qt中,显示一个对话框一般有两种方式,一种是使用exec()方法,它总是以模态来显示对话框;另一种是使用show()方法,它使得对话框既可以模态显示,也可以非 ...
当给控件设置settooptip时 如果控件的背景透明度设置为0 则tooltip会出现黑块
Qt中的多线程编程 文档选项 打印本页
QThread的用法! 分类:QT-trolltech2007-08-01 15:17 #include <qthread.h> class MyThread : public QThread { public: virtual void run(); }; void MyThread::run() { for( int count = 0; count < 20; count++ ) {sleep( 1 );qDebug( "Ping!" ); } } int main() { MyThread a; MyThread b ...
Qt: 多线程, 就是这么简单 #include<iostream>#include<QApplication>#include<QThread>#include<QString>classThread:publicQThread{public:Thread(QStringname=""){stopped=false;this->name=name;
一个QThread例子 //threadTest.h#ifndef THREADTEST_H#define THREADTEST_H #include <qthread.h>#include "test.h" class MyThread : public QThread{ protected : virtual void run();}; MyThread myThread; void Test::newSlot(){ myThread.start();} #endif //////////////////////////////// ...
CompleteLineEdit::keyPressEvent(QKeyEvent*e){ if(!listView->isHidden()){ intkey=e->key(); intcount=listView->model()->rowCount(); QModelIndexcurrentIndex=listView->currentIndex(); if(Qt::Key_Down==key){ //按向下方向键时,移动光标选中下一个完成列表中的项 ...
QStatusBar* bar = ui->statusBar;//获取状态栏 //还有种写法: //statusBar()->addWidget(locationLabel);//statusBar()->addWidget(formulaLabel, 1); first_statusLabel = new QLabel;//新建标签 first_statusLabel->setMinimumSize(150,20);//设置标签最小尺寸 first_statusLabel->setFrameShape(QFrame::WinPanel);// ...
文字对齐位置 //左对齐pushButton.setStyleSheet("QPushButton{text-align : left;}");//右对齐pushButton.setStyleSheet("QPushButton{text-align : right;}");
QApplication::setOverrideCursor(Qt::WaitCursor);//程序段QApplication::restoreOverrideCursor();注意,程序段一般为需要执行事件较长的语句组成,比如读写文件
Global site tag (gtag.js) - Google Analytics