PIXNET Logo登入

阿勇的blog

跳到主文

歡迎光臨阿勇在痞客邦的小天地

部落格全站分類:不設分類

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 3月 10 週日 201317:51
  • Qt5 + OpenGL



前幾天發現在Qt5裡,所有的fixed function pipeline都不能編譯了。稍微google了一下,才發現,原來Qt5所有precompile的安裝包,都是用ANGLE layer來實作OpenGL ES2,也就是你要寫的是OpenGL ES2,而不是OpenGL。所以一些fixed function pipeline的function,例如glBegin/glEnd都不能用了。
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(6)

  • 個人分類:Qt
▲top
  • 3月 08 週五 201322:22
  • Color Button for Qt (part 2)




void ColorButton::setColor(QColor color)
{
QPixmap pixmap(this->iconSize());
pixmap.fill(color);
this->setIcon(QIcon(pixmap));
selectedColor = color;
this->update();
}
void ColorButton::init(QColor color)
{
colorDialog.setCurrentColor(color);
QObject::connect(this, SIGNAL(clicked()),
&colorDialog, SLOT(open()));
QObject::connect(&colorDialog, SIGNAL(colorSelected(QColor)),
this, SLOT(setColor(QColor)));
setColor(color);
}
void ColorButton::paintEvent(QPaintEvent *event)
{
QPushButton::paintEvent(event);
QPainter painter(this);
painter.setCompositionMode(QPainter::CompositionMode_Screen);
painter.fillRect(0, 0, this->width(), this->height(), selectedColor);
}
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(11)

  • 個人分類:Qt
▲top
  • 3月 08 週五 201314:33
  • Color Button for Qt



void ColorButton::setColor(QColor color)
{
QPixmap pixmap(this->iconSize());
pixmap.fill(color);
QPainter painter;
painter.begin(&pixmap);
painter.setPen(0xffffff-color.rgb());
painter.drawRect(0,0, pixmap.width()-1, pixmap.height()-1);
painter.end();
this->setIcon(QIcon(pixmap));
}
void ColorButton::init(QColor color)
{
colorDialog.setCurrentColor(color);
QObject::connect(this, SIGNAL(clicked()),
&colorDialog, SLOT(open()));
QObject::connect(&colorDialog, SIGNAL(colorSelected(QColor)),
this, SLOT(setColor(QColor)));
setColor(color);
}
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(6)

  • 個人分類:Qt
▲top
  • 3月 04 週一 201313:49
  • 在Qt中,使用系統預設的圖示


QStyle定義了一些系統視窗相關的風格,像是圖示和gui的樣式。 qApp->style()->standardIcon(QStyle::SP_MediaVolumeMuted
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(23)

  • 個人分類:Qt
▲top
  • 3月 02 週六 201320:32
  • 3D text on Qt with OpenGL (part 2)



這一篇,是把上一篇的文章改成一個class
header file
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(7)

  • 個人分類:Qt
▲top
  • 3月 02 週六 201316:55
  • Qt 讀取非系統字型

使用QFontDatabase::addApplicationFont,可以直接讀取字型 檔(ttc, ttf)。

#include <QFontDatabase>
QString loadFontFromFile(QString path)
{
static QString font;
static bool loaded = false;
if(!loaded)
{
loaded = true;
int loadedFontID = QFontDatabase::addApplicationFont(path);
QStringList loadedFontFamilies = QFontDatabase::applicationFontFamilies(loadedFontID);
if(!loadedFontFamilies.empty())
font = loadedFontFamilies.at(0);
}
return font;
}
QString fontName = loadFontFromFile(":/font/font2.TTC");
QFont font(fontName);
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(130)

  • 個人分類:Qt
▲top
  • 3月 01 週五 201314:20
  • 3D text on Qt with OpenGL



利用QPainterPath算出polygon之後,就可以畫出邊框
QPainterPath path;
path.addText(QPointF(0, 0), QFont("Arial", 100), QString::fromUtf8("你要不要喝紅茶ˊ_>ˋ?"));
GLuint id = glGenLists(1);
glNewList(id, GL_COMPILE);
foreach(QPolygonF polygon, path.toSubpathPolygons()){
glBegin(GL_LINE_LOOP);
foreach(QPointF point, polygon){
glVertex3f(point.rx(), -point.ry(), 0);
}
glEnd();
}
glEndList();
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(2) 人氣(42)

  • 個人分類:Qt
▲top
  • 2月 18 週一 201318:29
  • QGraphicsProxyWidge在mac下無法調整大小


 
主要是Mac不像windows有邊框,所以不像windows只要
scene->addWidget(widget, Qt::Dialog);
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(2)

  • 個人分類:Qt
▲top
  • 4月 21 週四 201108:31
  • Qt creator + Qt lib + 中文化


1.download Qt library 4.7.2 and MinGW
2.install Qt to C:\Qt\4.7.2
3.unzip mingw.zip to c:\Qt
4.download Qt creator
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(37)

  • 個人分類:Qt
▲top
  • 3月 25 週五 201115:38
  • NetBeans+Qt


install NetBeans 6.9.1-cppdownload Qt library 4.7.2 and MinGWinstall Qtunzip mingw.zip to c:\Qtopen c:/Qt/4.7.2/mkspecs/default/qmake.confreplace $${DIR_SEPARATOR} as/run NetBeansTool->Options->c/c++->addBrowser->c:\Qt\mingw\bin->okQMake Command->c:\Qt\4.7.2\bin\qmake.exeFile->New Project->Sample->C/C++->Hello Qt WorldFile->Project Properties->Run->Configuration->All ConfigurationEnvironment->Path:C:\Qt\4.7.2\binnow run it
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(14)

  • 個人分類:Qt
▲top
123»

個人資訊

阿勇
暱稱:
阿勇
分類:
不設分類
好友:
累積中
地區:

熱門文章

  • (177)利用freetype轉出bitmap點陣字
  • (23)在Qt中,使用系統預設的圖示
  • (19)在mac中,建立應用程式的圖示(icns)
  • (3)在SQL中,當二個鍵同時相等時,唯一鍵成立。

文章分類

  • 替代役的日子 (5)
  • 黑色鈣片 (4)
  • java (3)
  • picasa (1)
  • lua (1)
  • mingw (1)
  • nsis (1)
  • squirrel (1)
  • freetype (1)
  • bitmap font (7)
  • windows (5)
  • c (1)
  • NetBeans (2)
  • uml (1)
  • html5 (1)
  • Wheel Light (4)
  • Qt (26)
  • opengl (6)
  • chrome (2)
  • hg (2)
  • mac (4)
  • apns (1)
  • python (4)
  • php (2)
  • SQL (4)
  • iOS (3)
  • xcode (4)
  • Objective-C (8)
  • phonegap (1)
  • swift (1)
  • cordova (2)
  • 未分類文章 (1)

最新文章

  • Cordova速記
  • Cordova run simulation
  • swift速記
  • cordova發布到andriod
  • 迷香
  • notification results in “unrecognized selector sent to instance…”
  • 分開設定xcode的configureration
  • 關於doesNotRecognizeSelector引起的exception crash
  • 在SQL中,當二個鍵同時相等時,唯一鍵成立。
  • 防止繼承的delegate跟原本的衝突(how to extend a protocol for a delegate in objective C)

最新留言

  • [15/08/24] 阿勇 於文章「3D text on Qt with O...」留言:
    抱歉很久回這裡了,今天才看到你的留言 你說的很多錯誤,是指?...
  • [15/06/29] 匿名 於文章「3D text on Qt with O...」留言:
    阿勇大大你好, 請問一下這個範例是可以輸入文字後將他轉成3D...
  • [12/05/30] 匿名 於文章「利用freetype轉出bitmap點陣...」留言:
    mac os x 10.7.4 gcc -o ayong ...
  • [11/10/02] 匿名 於文章「安裝程式-nsis...」留言:
    請問 MUI 跟 MUIXP 以外的介面怎麼設定的ㄚ?...
  • [09/02/24] 阿勇 於文章「Script language~Lua和...」留言:
    最近看到一個squirrel http://squirrel...
  • [09/02/24] 阿勇 於文章「Script language~Lua和...」留言:
    Lua有點冷門,而且好像沒有oo的慨念。...
  • [09/02/15] Barros Lee 於文章「Script language~Lua和...」留言:
    我推 Lua...

動態訂閱

文章精選

文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: