정리

Version Control with Subversion (for Subversion 1.7)

저장소/잡다한거

Version Control with Subversion

for Subversion 1.7


http://svnbook.red-bean.com/en/1.7/svn-book.html

SQLite - insert or replace (upsert)

저장소/VC++

데이터가 있으면 update 하고 없으면 insert 하는 방법을 찾다가 정리한다.

'insert or replace' 에 대한 내용은 아래 링크 참고.



INSERT OR REPLCAE example


SQLite Query Language: INSERT

SQLite Query Language: REPLACE

SQLite Query Language: ON CONFLICT clause


REPLACE


When a UNIQUE constraint violation occurs, the REPLACE algorithm deletes pre-existing rows that are causing the constraint violation prior to inserting or updating the current row and the command continues executing normally. If a NOT NULL constraint violation occurs, the REPLACE conflict resolution replaces the NULL value with the default value for that column, or if the column has no default value, then the ABORT algorithm is used. If a CHECK constraint violation occurs, the REPLACE conflict resolution algorithm always works like ABORT.


When the REPLACE conflict resolution strategy deletes rows in order to satisfy a constraint, delete triggers fire if and only if recursive triggers are enabled.


The update hook is not invoked for rows that are deleted by the REPLACE conflict resolution strategy. Nor does REPLACE increment the change counter. The exceptional behaviors defined in this paragraph might change in a future release.


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.

윈도우 재배치 깜빡임 줄이기 - DeferWindowPos

저장소/VC++

DeferWindowPos :

Updates the specified multiple-window – position structure for the specified window.


MSDN : http://msdn.microsoft.com/en-us/library/windows/desktop/ms632681(v=vs.85).aspx




원문 출처 : http://blog.naver.com/lcsco/120051320123


여러개의 윈도우 위치(multiple-window-position)를 위한 메모리를 할당하고 구조체에 Handle을 리턴한다.
여러개의 윈도우를 재배치 할때는 화면의 껌뻑임을 줄이기 위해 DeferWindowPos 함수를 사용한다.

 

사용방법은 메모리를 할당 한 후 사용하고 해제한다.

 

1.BeginDeferWindowPos(메모리 할당)

 

HDWP BeginDeferWindowPos(
  int nNumWindows   // number of windows
);
여러개의 윈도우 위치(multiple-window-position)를 위한 메모리를 할당하고 구조체에 Handle을 리턴한다.

 

 

2.DeferWindowPos

 

HDWP DeferWindowPos(
  HDWP hWinPosInfo,      // handle to internal structure
  HWND hWnd,             // handle to window to position
  HWND hWndInsertAfter,  // placement-order handle
  int x,                 // horizontal position
  int y,                 // vertical position
  int cx,                // width
  int cy,                // height
  UINT uFlags            // window-positioning flags
);


열거된 여러개의 윈도우 위치(multiple-window-position)를 업데이트한다. 
업데이트된 구조체의 핸들을 리턴한다.

hWinPosInfo : 한개이상의 윈도우에 대한 크기, 위치정보를 포함한 multiple-window-position 구조체 핸들
              이 구조체는 비공개 구조체로 BeginDeferWindowPos에 의해 리턴되거나 최근에 콜한 DeferWindowPos에 의해 리턴된다.
hWnd : handle to window to position
hWndInsertAfter : placement-order handle(SetWindowPos 참조)
x,y : 위치
cx, cy : 크기
uFlag : window-positioning flags(SetWindowPos 참조)

 

리턴값 : 업데이트된 구조체

 

3.EndDeferWindowPos(메모리 해제 및 변경)

 

BOOL EndDeferWindowPos(
  HDWP hWinPosInfo   // handle to internal structure
);

한번의 리플레쉬로 한개이상의 윈도우의 위치,사이즈를 동시에 변경한다.

 

[출처] DeferWindowPos|작성자 길상


How to use VC_EXTRALEAN and WIN32_LEAN_AND_MEAN to enhance the build process in Visual C++

저장소/VC++

가끔 보는 WIN32_LEAN_AND_MEAN 전처리기 의미는 무엇인가?

볼 때마다 찾아보지 않으려면 기록.


WIN32_LEAN_AND_MEAN 을 정의하므로써

거의 사용하지 않는 파일을 제외하여 빌드 시간을 단축할 수 있다고 한다.

windows.h 를 참고하라고 하네.


출처 : http://support.microsoft.com/kb/166474/en-us (http://support.microsoft.com/kb/166474/ko)



흥배님 블로그에 WIN32_LEAN_AND_MEAN 에 대해 보다 자세한 내용이 정리되어 있다.

http://jacking.tistory.com/502

무어의 법칙과 프리컴파일드 헤드가 WIN32_LEAN_AND_MEAN을 거의 불필요하게 해 버렸다이미 시간의 단축은 되지 않는다그러나 어느 시대에서는 확실히 도움이 되었던 것이었다.


더는 의미 없는거네.



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

PSAPI 사용 주의

저장소/VC++

OS version에 따른 PSAPI 사용에 주의 필요.


다음은 PSAPI 의 EunumProcesses API 의 MSDN 내용 일부 발췌.

If PSAPI_VERSION is 2 or greater, this function is defined as K32EnumProcesses in Psapi.h and exported in Kernel32.lib and Kernel32.dll. If PSAPI_VERSION is 1, this function is defined as EnumProcesses in Psapi.h and exported in Psapi.lib and Psapi.dll as a wrapper that calls K32EnumProcesses.

Programs that must run on earlier versions of Windows as well as Windows 7 and later versions should always call this function as EnumProcesses. To ensure correct resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program with –DPSAPI_VERSION=1. To use run-time dynamic linking, load Psapi.dll.



Kernel32.lib on Windows 7 and Windows Server 2008 R2;

Psapi.lib if PSAPI_VERSION=1 on Windows 7 and Windows Server 2008 R2;
Psapi.lib on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP

간단히 요약하면 PSAPI_VERSION 정의값이 1이면 psapi.lib/dll 에서 사용, PSAPI_VERSION 정의값이 2 이상이면 kernel32.lib/dll에서 사용한다고 함.

Windows 7, Windows Server 2008 R2 이전 버전의 OS에서 PSAPI 를 올바르게 사용하려면 PSAPI_VERSION 정의값을 1로 설정하여 psapi.lib/dll 을 사용하도록 해야함.


PSAPI Functions

http://msdn.microsoft.com/en-us/library/windows/desktop/ms684894(v=vs.85).aspx


Visual C++ Team Blog :

Windows SDK V7.0/V7.0A Incompatibility Workaround

http://blogs.msdn.com/b/vcblog/archive/2009/08/27/windows-sdk-v7-0-v7-0a-incompatibility-workaround.aspx




ADS(Alternate Data Streams)

저장소/잡다한거


익스플로러를 통해 다운로드 받은 실행 파일을 ShellExecute(Ex) API 를 통해 실행했을 때 실패 발생.

GetLastError의 값이 1223으로 나옴.

//
// MessageId: ERROR_CANCELLED
//
// MessageText:
//
// The operation was canceled by the user.
//
#define ERROR_CANCELLED                  1223L


탐색기에서 파일을 실행하면 다음과 같이 경고창이 뜬다.



파일 속성을 보면 다음과 같이 보안 항목이 표된다.



뭔지 찾아보니 NTFS의 ADS(Alternate Data Streams)와 관련이 있다고 한다.

다음은 ADS에 대한 정리가 잘 되어있는 링크니 참고해서 보자.


파일 열기 보안 경고

http://snoopybox.co.kr/1552


Hidden Threat: Alternate Data Streams

http://coinz.tistory.com/115


Data Hiding 기법 - ADS 생성/실행/탐지


Fork(file system)

Enumerating Alternate Data Streams

Manipulate Alternate Data Streams

http://www.codeproject.com/Articles/9387/Manipulate-Alternate-Data-Streams