정리

Qt 5.x GUI 프로젝트 opengl 관련 빌드 오류

저장소/Qt

Qt 5.x GUI 프로젝트를 새로 만들어서 빌드할 때 다음과 같은 에러가 발생한다면


1>C:\Qt\Qt5.1.1\5.1.1\msvc2012\include\QtGui/qopengl.h(82): fatal error C1083: 포함 파일을 열 수 없습니다. 'GLES2/gl2.h': No such file or directory


추가 포함 디렉토리에 아래와 같이 추가하여 다시 빌드하면 정상 빌드된다.


$(QTDIR)\include\QtANGLE


Qt OpenGL 라이브러리는 추가하지 않아도 된다.

'저장소 > Qt' 카테고리의 다른 글

Style Sheet Syntax : Selector  (0) 2013.11.27
Qt Style Sheets (Qt 5.1)  (0) 2013.11.22
Drop Shadow Effect  (0) 2013.11.19
QImage, QPixmap의 loadFromData, bitmap image header, resource dll  (0) 2013.10.30
widget 프레임 제거와 배경 투명화  (0) 2013.10.30

Style Sheet Syntax : Selector

저장소/Qt


Qt Style Sheet로 이것저것 해보는 중에 차이가 잘 이해되지 않는 것

이것과
".QWidget {"
"background-color: rgba(0, 0, 0, 100%); }"
이것의
"QWidget {"
"background-color: rgba(0, 0, 0, 100%); }"
차이점은?

결론은 나만 적용할 것인가, 하위 위젯에도 동일하게 적용할 것인가의 차이.



Qt Centre에 아래 질문 올라옴.
http://www.qtcentre.org/threads/30221-Style-Sheet-Syntax-background
    Q: Style Sheet Syntax background


I want to have the background only from a QWidget black. The background from the QPushbuttons, QSliders etc. shoud be normal.

I use the Style-Syntax:


QWidget {

background-color:rgb(20, 20, 20);

}


I read in the Qt Assistant (Stylesheet-Syntax) that i must make bevore the QWidget a point:


.QWidget {

background-color:rgb(20, 20, 20);

}


I have now the problam that this didn't work. 


Thanks for help.



A:

well it works, but only for QWidgets! No subclass, even not your own if they only inherit QWidget.


maybe you provide a small executable example showing your problem.





The Style Sheet Syntax

http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html

Selector Types

All the examples so far used the simplest type of selector, the Type Selector. Qt Style Sheets support all the selectors defined in CSS2. The table below summarizes the most useful types of selectors.

SelectorExampleExplanation
Universal Selector*Matches all widgets.
Type SelectorQPushButtonMatches instances of QPushButton and of its subclasses.
Property SelectorQPushButton[flat="false"]Matches instances of QPushButton that are not flat. You may use this selector to test for any Qt property that supports QVariant::toString() (see the toString()function documentation for details). In addition, the special class property is supported, for the name of the class.

This selector may also be used to test dynamic properties. For more information on customization using dynamic properties, refer toCustomizing Using Dynamic Properties.

Instead of =, you can also use ~= to test whether a Qt property of typeQStringList contains a given QString.

Warning: If the value of the Qt property changes after the style sheet has been set, it might be necessary to force a style sheet recomputation. One way to achieve this is to unset the style sheet and set it again.

Class Selector

.QPushButton

Matches instances of QPushButton, but not of its subclasses.

This is equivalent to *[class~="QPushButton"].

ID SelectorQPushButton#okButtonMatches all QPushButton instances whose object name is okButton.
Descendant SelectorQDialog QPushButtonMatches all instances of QPushButton that are descendants (children, grandchildren, etc.) of a QDialog.
Child SelectorQDialog > QPushButtonMatches all instances of QPushButton that are direct children of a QDialog.






Qt Style Sheets (Qt 5.1)

저장소/Qt

Qt Style Sheets

출처: http://qt-project.org/doc/qt-5.1/qtwidgets/stylesheet.html


Qt Style Sheets are a powerful mechanism that allows you to customize the appearance of widgets, in addition to what is already possible by subclassing QStyle. The concepts, terminology, and syntax of Qt Style Sheets are heavily inspired by HTML Cascading Style Sheets (CSS) but adapted to the world of widgets.

Topics:

Overview

Styles sheets are textual specifications that can be set on the whole application using QApplication::setStyleSheet() or on a specific widget (and its children) using QWidget::setStyleSheet(). If several style sheets are set at different levels, Qt derives the effective style sheet from all of those that are set. This is called cascading.

For example, the following style sheet specifies that all QLineEdits should use yellow as their background color, and allQCheckBoxes should use red as the text color:

QLineEdit { background: yellow }
QCheckBox { color: red }

For this kind of customization, style sheets are much more powerful than QPalette. For example, it might be tempting to set the QPalette::Button role to red for a QPushButton to obtain a red push button. However, this wasn't guaranteed to work for all styles, because style authors are restricted by the different platforms' guidelines and (on Windows XP and Mac OS X) by the native theme engine.

Style sheets let you perform all kinds of customizations that are difficult or impossible to perform using QPalette alone. If you want yellow backgrounds for mandatory fields, red text for potentially destructive push buttons, or fancy check boxes, style sheets are the answer.

Style sheets are applied on top of the current widget style, meaning that your applications will look as native as possible, but any style sheet constraints will be taken into consideration. Unlike palette fiddling, style sheets offer guarantees: If you set the background color of a QPushButton to be red, you can be assured that the button will have a red background in all styles, on all platforms. In addition, Qt Designer provides style sheet integration, making it easy to view the effects of a style sheet in different widget styles.

In addition, style sheets can be used to provide a distinctive look and feel for your application, without having to subclass QStyle. For example, you can specify arbitrary images for radio buttons and check boxes to make them stand out. Using this technique, you can also achieve minor customizations that would normally require subclassing several style classes, such as specifying a style hint. The Style Sheet example depicted below defines two distinctive style sheets that you can try out and modify at will.

Coffee theme running on Windows XPPagefold theme running on Windows XP
Coffee theme running on Ubuntu LinuxPagefold theme running on Mac OS X

When a style sheet is active, the QStyle returned by QWidget::style() is a wrapper "style sheet" style, not the platform-specific style. The wrapper style ensures that any active style sheet is respected and otherwise forwards the drawing operations to the underlying, platform-specific style (e.g., QWindowsXPStyle on Windows XP).

Since Qt 4.5, Qt style sheets fully supports Mac OS X.

Warning: Qt style sheets are currently not supported for custom QStyle subclasses. We plan to address this in some future release.

Drop Shadow Effect

저장소/Qt

frameless windows에 drop shadow 효과 주는 방법



원문 출처 : stackoverflow

http://stackoverflow.com/questions/12347776/how-to-put-a-shadow-to-a-frameless-window-in-qt



Q: How to put a shadow to a Frameless window in Qt


A: 

Add a "QWidget" (say widget) to the MainWindow and move everything that's on the MainWindow to the widget. Then do this:

setAttribute(Qt::WA_TranslucentBackground); //enable MainWindow to be transparent

QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(5);
ui->widget->setGraphicsEffect(effect);

This seems to work for me. See:

illusion of a main window having a shadow

'저장소 > Qt' 카테고리의 다른 글

Style Sheet Syntax : Selector  (0) 2013.11.27
Qt Style Sheets (Qt 5.1)  (0) 2013.11.22
QImage, QPixmap의 loadFromData, bitmap image header, resource dll  (0) 2013.10.30
widget 프레임 제거와 배경 투명화  (0) 2013.10.30
이미지 버튼  (0) 2013.10.30

QImage, QPixmap의 loadFromData, bitmap image header, resource dll

저장소/Qt
QImage or QPixmap의 다음 함수 사용시 주의점
	bool	loadFromData(const uchar * data, int len, const char * format = 0)
	bool	loadFromData(const QByteArray & data, const char * format = 0)

읽을 대상 이미지가 비트맵의 경우 해당 헤더 정보가 없으면 loadFromData 함수 사용시 결과가 실패 떨어진다.

다른 이미지 파일은 안 해봐서 모름.

이미지 파일을 읽어서 사용할 땐 문제가 없으나 resource dll에서 비트맵을 읽어왔을 때 문제 발생.

resource dll에 Bitmap Image를 추가할 때 헤더 정보가 빠지는 것 같다.

이럴 땐 리소스를 추가할 때 Bitmap으로 추가하지 말고 '사용자 지정 리소스' 타입으로 만들어서 추가하면 된다.

(.rc 파일을 직접 건드려야 할 것이야!)


'저장소 > Qt' 카테고리의 다른 글

Qt Style Sheets (Qt 5.1)  (0) 2013.11.22
Drop Shadow Effect  (0) 2013.11.19
widget 프레임 제거와 배경 투명화  (0) 2013.10.30
이미지 버튼  (0) 2013.10.30
프로세스 실행경로 확인  (0) 2013.10.30

widget 프레임 제거와 배경 투명화

저장소/Qt

widget의 윈도우 프레임을 제거하는 방법.


void SomeWidget::foo()
{
	setAttribute(Qt::WA_TranslucentBackground, true); // 배경 투명하게
	setWindowFlags(Qt::FramelessWindowHint); // 프레임 제거
}


QWidget 을 상속받는 widget에 모두 사용 가능하다?

안 해봐서 모름.


'저장소 > Qt' 카테고리의 다른 글

Drop Shadow Effect  (0) 2013.11.19
QImage, QPixmap의 loadFromData, bitmap image header, resource dll  (0) 2013.10.30
이미지 버튼  (0) 2013.10.30
프로세스 실행경로 확인  (0) 2013.10.30
Qt 커뮤니티 및 블로그, 버그  (0) 2013.09.06

이미지 버튼

저장소/Qt

QPushButton에 이미지 올리기와 enter/leave/press/release event에서의 이미지 변경.


class button : public QPushButton
{
	...

	void setImage(QPiaxmap& _pixmap)
	{
		QSize size;
		size.setWidth(_pixmap.width() / 4);
		size.setHeight(_pixmap.height());

		m_icons[Normal] = (QIcon(_pixmap.copy(Normal * size.width(), 0, size.width(), size.height())));
		m_icons[Click] = (QIcon(_pixmap.copy(Click * size.width(), 0, size.width(), size.height())));
		m_icons[Highlight] = (QIcon(_pixmap.copy(Highlight * size.width(), 0, size.width(), size.height())));
		m_icons[Disable] = (QIcon(_pixmap.copy(Disable * size.width(), 0, size.width(), size.height())));

		if(isEnabled())	setIcon(m_icons[Normal]);
		else			setIcon(m_icons[Disable]);
	
		setIconSize(m_size);
		resize(m_size);
	}
	virtual void	enterEvent(QEvent* _event)
	{
		__super::enterEvent(_event);

		if(isEnabled())
			setIcon(m_icons[Highlight]);
	}
	virtual void leaveEvent(QEvent* _event)
	{
		__super::leaveEvent(_event);

		if(isEnabled())
			setIcon(m_icons[Normal]);
	}
	virtual void mousePressEvent(QMouseEvent* _event)
	{
		__super::mousePressEvent(_event);
	
		if(isEnabled())
			setIcon(m_icons[Click]);
	}
	virtual void mouseReleaseEvent(QMouseEvent* _event)
	{
		__super::mouseReleaseEvent(_event);

		if(isEnabled())
			setIcon(m_icons[Highlight]);
	}
	virtual void changeEvent(QEvent* _event)
	{
		__super::changeEvent(_event);

		if(QEvent::EnabledChange != _event->type())
			return;

		if(isEnabled())	setIcon(m_icons[Normal]);
		else			setIcon(m_icons[Disable]);
	}

};


와.. vector<QIcon> m_icons; 요거 쓸라니까 syntaxhighlighter에서 </qicon>을 붙여버리네 ㅡ,.ㅡ

버튼 이미지는 연속된 4개의 이미지가 하나의 파일로 제작되었을 때를 가정,

m_icons는 vector<QIcon>으로 size는 4로 미리 정의.


프로세스 실행경로 확인

저장소/Qt

번거롭다.


char temp[MAX_PATH] = {0,};
::GetModuleFileNameA(NULL, temp, MAX_PATH);
QFileInfo info(temp);
QString workingDir = QDir::toNativeSeparators(info.absoluteDir().path());


QFileInfo를 통해 획득한 absoluteDir을 보면 경로의 구분자가 '\'가 아닌 '/'로 되어있다.

예) C:\Windows\System32    ->    C;/Windows/System32

이를 원래의 윈도우즈 경로로 변경하려면 QDir의 static 함수인 toNativeSeparators를 사용하면 된다!

'저장소 > Qt' 카테고리의 다른 글

Drop Shadow Effect  (0) 2013.11.19
QImage, QPixmap의 loadFromData, bitmap image header, resource dll  (0) 2013.10.30
widget 프레임 제거와 배경 투명화  (0) 2013.10.30
이미지 버튼  (0) 2013.10.30
Qt 커뮤니티 및 블로그, 버그  (0) 2013.09.06

Qt 커뮤니티 및 블로그, 버그

저장소/Qt


국내 커뮤니티 : http://www.korone.net/qt.php



개인 블로그

구리님 : http://dgoh.tistory.com/category/QT



뻐그

https://bugreports.qt-project.org/browse/QTBUG-29109


기타

http://qt-project.org/wiki/Build_Standalone_Qt_Application_for_Windows


ICO Image Format

http://doc.qt.digia.com/solutions/4/qticoimageformat/



Stylesheet Example

http://qt-project.org/doc/qt-4.8/stylesheet-examples.html


how to set $(QTDIR) path in visual studio

http://smh0816.egloos.com/3362003

'저장소 > Qt' 카테고리의 다른 글

Drop Shadow Effect  (0) 2013.11.19
QImage, QPixmap의 loadFromData, bitmap image header, resource dll  (0) 2013.10.30
widget 프레임 제거와 배경 투명화  (0) 2013.10.30
이미지 버튼  (0) 2013.10.30
프로세스 실행경로 확인  (0) 2013.10.30