Time of Update: 2018-12-05
我們在編寫Qt程式時經常會遇到這樣的需求: 讓程式等待一段時間, 這段時間裡可能程式什麼都不做, 也可能是在後台開了個子線程在做一些使用者看不見的工作。首先我們容易想到的方法是使用類似linux提供的”sleep”或”usleep”函數。 但用過這組函數的Qter都知道, 這組函數會將你當前的線程/進程變為“睡眠”狀態。 這個“睡眠”是深度意義的睡眠, 睡眠期間核心不會分配給程式時間片, 所以程式什麼都不做, 更不用提介面的重新整理了。 直接導致的問題就是使用者無法與程式互動。
Time of Update: 2018-12-05
規則表單的實現 準備兩個圖,一個是要顯示在表單的圖片,一個是蒙板,蒙板的黑色部分是要保留的,白色是要去掉的。 我準備了2張圖,要顯示的圖片是"tmp.png",蒙板是"mask.png". 下面的程式都有個毛病,不能拖出幕視窗以外,為什麼呢? 請注意一個是視窗和MASK圖片的大小問題,還有就是只有無拖動欄的表單MASK成不規則表單才允許拖出螢幕視窗以外。 GTK程式參考 gtk_widget_shape_combine_mask tmp.png (2.41 KB) 使用
Time of Update: 2018-12-05
QT中的多線程(一)/************************************華麗麗的分割線*************************************/這篇文章和以下的一篇文章 QT中的多線程(二)皆為轉載文章,文章轉自:http://www.cppblog.com/yuanyajie/archive/2007/08/22/30599.html十分感謝原文作者,幫我解決了近幾日的疑惑,對於QT的線程間的通訊有了進一步瞭解,在這裡向他致以我崇高的敬意。/******
Time of Update: 2018-12-05
Qt:平台相關的代碼寫法#ifdef Q_OS_LINUX#ifdef V4L rc = new V4L1VideoCaptureDevice;#endif //V4L#endif //Q_OS_LINUX #ifdef Q_OS_WIN32 rc = new CvVideoCaptureDevice;#endif // Q_OS_WIN32 } else { rc = new XvidVideoCaptureDevice( file );
Time of Update: 2018-12-05
以下是實現areo效果的類,以及使用方法: ************************main.cpp****************************** #include <QtGui>#include "aero.h" int main(int argc,char*argv[]){ QApplication app(argc,argv); QMainWindow w;w.resize(900,900);
Time of Update: 2018-12-05
QT中幾種設定控制項的圖片背景的方法杯具了,知道今天才發現有不少種可以載入圖片的方法。 下面簡單總結下: 1 MLCNWidget *w=new MLCNWidget;w->setAutoFillBackground(true);QPalette palette;palette.setBrush(w->backgroundRole(),
Time of Update: 2018-12-05
self.table=QTableWidget() #執行個體化self.table.setColumnCount(4) #設定列數self.table.setRowCount(6) #設定行數self.table.setWhatsThis("mantou") ###self.table.setEditTriggers(QTableWidget.NoEditTriggers) #設定為不能編輯儲存格#set Column tab
Time of Update: 2018-12-05
startDetached啟動的LibFx.exe跟你的進程沒關係,你的程式關了它還可以繼續運行QString strFile=tr("E:/f/LibFx.exe");QProcess* pProcess=new QProcess(this);pProcess->startDetached(strFile);//start()的話,LibFx.exe是你當前進程的子進程,你的程式關掉,LibFx.exe也關掉了。 或者這種 帶調試資訊的 void
Time of Update: 2018-12-05
我們知道,QTable裡有一個removeRow(int i)函數用來刪除當前行,但是如果我們沒有對於table進行任何的選中,那麼QTable是如何返回的呢?用Designer裡拖了一個tableWidget,加一個按鈕,點擊刪除後執行int i = ui.tableWidget->currentRow();QMessageBox
Time of Update: 2018-12-05
我們知道,在可視化的資料庫軟體中,一般都支援點擊列名然後使該列下的值進行排序。那麼在QT下,我們該如何?這種效果呢? 查看QT文檔的QHeaderView類,發現其中有pressed和clicked訊號,然後在QTableWidget的父類QTableView中可以看到sortByColumn()這個API,是按照某一列進行排序的,於是可以自訂一個槽函數sortSlot(),如下定義: void
Time of Update: 2018-12-05
建立狀態,設定狀態中的屬性,設定初始狀態,設定狀態裝換條件、動畫,啟動狀態機器 int nMargin = 9; int nInitWidth = m_pSelMoldForm->width(); int nInitHeight = m_pSelMoldForm->height(); int nConfEpyFormW = m_pConfEpyProForm->width(); int nConfEpyFormH =
Time of Update: 2018-12-05
控制QLineEdit的輸入範圍 1.使用Regex檢驗QLineEdit的輸入範圍(代碼如下):#include <qvalidator.h>#include <qlineedit.h> QLineEdit *lineEdit = new QLineEdit(this);QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}"); //^[1-9][0-9]*$ 和 ^[1-9]{1}[/d]*$
Time of Update: 2018-12-05
IAlertView *alert =[[UIAlertView alloc]initWithTitle:@"hello" message:@"ipad ,i come" delegate:self cancelButtonTitle:@"ok"
Time of Update: 2018-12-05
有這樣一個程式: #include <QtGui/QApplication> #include <qtextcodec.h>#include <QtGui/QDialog>#include <QtCore/QTimer>#include "widget.h"int main(int argc, char
Time of Update: 2018-12-05
//縮放動畫 CABasicAnimation *scalAni = [CABasicAnimationanimationWithKeyPath:@"transform.scale"]; scalAni.fromValue = [NSNumbernumberWithFloat:1]; scalAni.toValue =
Time of Update: 2018-12-05
void MainWindow::createStatusBar(){ locationLabel = new QLabel(" W999 ");//以文字" W999 " 建立 一個新的QLabel的對象 locationLabel->setAlignment(Qt::AlignHCenter);//文字對齊為中間對齊
Time of Update: 2018-12-05
找了下,發現在QAbstractScrollArea裡面有void setHorizontalScrollBar ( QScrollBar * scrollBar )void setHorizontalScrollBarPolicy ( Qt::ScrollBarPolicy )void setVerticalScrollBar ( QScrollBar * scrollBar )void setVerticalScrollBarPolicy ( Qt::ScrollBarPolicy
Time of Update: 2018-12-05
先在工程檔案中加入TRANSLATION += ***.ts然後命令列輸入lupdate ***.pro開啟.ts檔案,一條一條的翻譯就是了最後lrelease ***.pro 在main函數裡加代碼就不用我說了吧 TRANSLATIONS += Assist_zh_CN.ts / Assist_fr_FR.ts #include <QtGui/QApplication>#include "unikeyassist.h"#include
Time of Update: 2018-12-05
The CAAnimation and CALayer classes extend theNSKeyValueCoding protocol adding default values for keys, expanded wrapping conventions, and key path support forCGPoint,CGRect, CGSize, and CATransform3D.Key-Value Coding Compliant Container ClassesBoth
Time of Update: 2018-12-05
Qt: 釋放視窗資源1. 對於使用指標,使用new建立的視窗,當然可以使用delete顯示的釋放其佔用的資源:Widget *w = new Widget();delete w; 2. 對於使用指標,使用new建立的視窗,還可以使用QWidget::setAttribute方法來當視窗關閉後自動釋放其佔用的資源,而不使用者顯示的去調用delete釋放,此方法當然也會調用視窗的解構函式:Widget *w = new