본문 바로가기

프로그래밍/시스템

(53)
C++ Qt 배경화면 투명도 설정 1 2 3 4 setAutoFillBackground(false); setWindowFlags(Qt::Tool | Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); ui->setupUi(this); Colored by Color Scripter cs 1. 배경 채우지 않기 2. 테두리 제거 플레이그 설정 , 다이얼로그인 경우 Tool 설정 3. 배경 제거 자세한 내용 : http://doc.qt.io/qt-5/qwidget.html 위 작업은 배경을 지우는 과정이였고 ,이제 배경을 새로 그려줍니다. 1 2 3 4 5 6 7 8 9 10 11 #include ... void mybackground::paintEvent(QPaintE..
C++ Qt window flags http://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html http://doc.qt.io/qt-5/qt.html#WindowState-enum 필드 요약 static Qt.WindowType BypassGraphicsProxyWidget QGraphicsProxyWidget부모 위젯이 이미 포함 되어있는 경우 창과 해당 하위 항목이 자동으로 포함되지 않도록합니다 . static Qt.WindowType CustomizeWindowHint 기본 창 제목 힌트를 끕니다. static Qt.WindowType Desktop 이 위젯이 데스크탑임을 나타냅니다. static Qt.WindowType Dialog 위젯이 대화 상자로 장식되어야하는 창임을 나타..
C++ Qt 다이얼로그 데이터 전송 ▶ 새 다이얼로그 생성 프로젝트 폴더 우클릭 --> Add new Dialog 템플릿 선택 ▶ MainWindow와 다이얼로그간 데이터 전송 왼쪽 창은 메인창이고 오른쪽은 새 다이얼로그입니다. 데이터 전송 절차는 다음과 같습니다. 1. Go to Dialog 버튼을 클릭하면 새 다이얼로그를 띄웁니다. 그와 동시에 메인의 Value도 새 다이얼로그로 넘깁니다. 2. 새 다이얼로그의 Input을 누르면 메인에서 받아온 Value값과 LineEdit에서 입력한 값을 더하여 멤버변수에 저장시킵니다. 3. 그 후 Main에서 새 다이얼로그의 멤버변수 값을 가져옵니다. mainwindow.h 1 2 3 4 5 6 7 8 9 #include #include "dialog.h" ... ... signals: void ..
C++ Qt 메시지박스 http://doc.qt.io/qt-5/qmessagebox.html Qt에서 메시지박스를 사용하려면 다음과 같은 헤더파일이 필요합니다. 1 #include cs 전형적인 OK Cancle 버튼 예제 1 2 3 4 5 6 7 8 9 10 QMessageBox MsgBox; MsgBox.setText("프로그램을 종료하시겠습니까?"+); // MsgBox.setInformativeText("프로그램을 종료하시겠습니까?"); MsgBox.setStandardButtons(QMessageBox::Ok |QMessageBox::Cancel); MsgBox.setDefaultButton(QMessageBox::Ok); if ( MsgBox.exec() == QMessageBox::Ok ) { this->close..
C++ Qt 정규식 http://doc.qt.io/qt-5/qregexp.html Qt에서 정규식을 사용하려면 다음과 같은 헤더파일이 필요합니다. 1 #include cs ▶ 예제1 - 첫 번째 문자가 숫자인지 검사 1 2 3 4 5 6 7 QRegExpValidator validator(QRegExp("\\d"),0); QString text = "7"; int pos = 0; if ( validator.validate(text,pos) == validator.Acceptable ) { qDebug() setValidator(validator); ui->IpEdit2->setValidator(validator);ui->IpEdit3->setValidator(validator); ui->IpEdit4->setValidato..
C++ Qt 파일 입출력 , 파일 변화 감지 # 파일 입출력 , 파일 변화 감지 h 1 2 #include #include cs ▶ 파일 존재 여부 체크 1 QFile::exists(path) cs ※ true = exists ▶ 파일 입출력 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 void MainWindow::Read(QString path) { QFile file(path); // path 형식 "C://dir//hi.txt" if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug()
C++ Qt TreeWidget .행에는 여러 개의 데이터 열이 포함되며 각 열에는 텍스트 레이블과 아이콘이 포함될 수 있습니다. 관련문서:http://doc.qt.io/qt-5/search-results.html?q=treewidget 트리위젯을 사용하기 위해서는 다음과 같은 헤더파일이 필요합니다. #include ● 트리위젯의 구성 ① 기본 트리위젯 구성 예제 ▷ 트리위젯의 헤더를 만들기 위한 코드는 다음과 같습니다. 1 2 3 4 5 QTreeWidgetItem* header = new QTreeWidgetItem; header->setText(0, "User"); header->setText(1, "OS"); header->setText(2, "Version"); ui->treeWidget->setHeaderItem(header..
C++ Qt 간단한 로그인 폼 만들기 ● 레이아웃 구성 ▷ Login 표시 라벨과 나가기 버튼 ▷ Username 표시 라벨 & 텍스트 에디트 ▷ Password 표시 라벨 & 텍스트 에디트 ▷ 로그인 버튼 ▶ step1 위젯 배치 ▶ step2 Horizontal Layout(수직바)으로 각 위젯을 묶기 ▶ step3 전체 Layout을 잡은 뒤 Vertical Layout(수평바) 설정 ▶ step4 위젯 사이의 간격을 주고 Login버튼을 중앙으로 배치하기 위해 Horizontal Spacer(가로여백) 사용 ▶ 결과