* 함수 - http://blog.daum.net/coolprogramming/60

함수 인자에 붙는 const
    인자가 포인터나 레퍼런스인 경우 함수 내에서 변경 불가능 하게 한다!! (in 파라메터인 경우)

함수 이름 뒤에 붙는 const
    멤버 함수에만 사용되며 멤버 변수의 내용을 변경하지 않는 다는 의미
    const 객체는 const 멤버 함수만 호출할 수 있다.

리턴 자료형에 붙는 const
    포인터나 레퍼런스를 리턴할 때 변경 불가능 하도록 한다.



* 변수 - http://ndd247-dev.tistory.com/5



* 클래스간의 형 변환 (대입)

    * 자식 클래스를 부모 클래스로 대입 불가능!!
        =======>>> 대입 연산자를 재정의 하면 되지 않을까??


    * 자식클래스의 포인터에 부모 클래스를 넣는것 불가능!!

    * 부모 클래스의 포인터에 자식 클래스를 넣는 것 가능!!!


        childClass classB;

        parentClass *classA = &classB;
        parentClass &classC = &classB;

            classA에서 함수를 호출했는데 parentClass childClass 모두에 존재, 어떤것이 호출될까?

            ==> 호출되는 함수가 가상함수(virtual)인 경우는 자식 클래스의 함수가 호출되고,
                일반 함수일 경우 포인터 타입을 기준으로 함수가 호출된다.
                위 경우 classA, classC의 함수가 호출됨



button6.clicked.connect( lambda temp="",name="Button6": self.ButtonClick(name) )


temp를 두지 않으면 slot method(ButtonClick()) 로 넘어가는 값이 원하는 값(name)이 아니라

boolean 값이 넘어간다.


왜 그런지 이유를 모르겠다.

어쨌거나 이렇게해서 원하는 name 값이 정확히 ButtonClick 메소드로넘어가게 할 수 있다.





QTableView


setShowGrid(False)

verticalHeader().setVisible(False)

horizontalHeader().setVisible(True)


setSelectionBehavior(QAbstractItemView.SelectRows) # row 전체를 선택하도록

setSelectionMode(QAbstractItemView.SingleSelection)

setEditTriggers(QAbstractItemView.NoEditTriggers) # 셀 내용을 수정 불가하도록


  model = QStandarItemMode()

setModel( model ) # 당연히 모델을 먼저 만들어야 한다.


setColumnWidth(model.columnCount()-1, 120) # 컬럼수가 정해져야 적용 가능

setRowHeight(model.rowCount()-1, 20) # row마다 적용해야함



QStandardItemModel


setColumnCount(2)               # QTableView의 setColumnWidth/setRowHeight 함수를 사용하려면 필요함

  # setRowCount(2)

  # header는 QTableView가 아닌 QStandardItemModel이 갖는다.

setHorizontalHeaderLabels( [ "name", "address" ] ) # 컬럼 갯수만큼


  # 꼭 []나 () 형태로 넘겨야함

appendRow( [ QStandardItem( "" ) ] )


item( index.row(), index.row() ).data( Qt.DisplayRole )



"""#!C:\Python34\python.exe"""


# -*- coding: utf-8 -*-


import sys

from PyQt5.QtWidgets import *


# 아래 명령으로 생성된 클래스들 

# pyuic5 *.ui -o *_ui.pyw

from mainwindow_ui import *

from dialog_ui import *

from widget_ui import *


class WindowMain(QMainWindow):

def __init__(self, parent=None):

QMainWindow.__init__(self, parent)

self.ui = Ui_MainWindow() # mainwindow_ui.pyw

self.ui.setupUi(self)


""" 위의 표현이 맞는거 같다. (아래 코드도 동작을 하긴 하는데...)

def __init__(self):

super(WindowMain,self).__init__()

self.ui = Ui_MainWindow()

self.ui.setupUi(self)


def __init__(self, parent=None):

super()__init__(parent)

self.ui = Ui_MainWindow()

self.ui.setupUi(self)


"""


class DialogMain(QDialog):

def __init__(self, parent=None):

QDialog.__init__(self, parent)

self.ui = Ui_Dialog() # dialog_ui.pyw

self.ui.setupUi(self)


class FormMain(QWidget):

def __init__(self, parent=None):

QWidget.__init__(self, parent)

self.ui = Ui_Form() # widget_ui.pyw

self.ui.setupUi(self)


if __name__ == "__main__":

app = QApplication( sys.argv )


mainWin = WindowMain()

mainWin = DialogMain()

mainWin = FormMain()

mainWin.show()


app.exec_()



%%%
Qt Designer 에서 Dialog로 만든 UI는 반드시 QDialog를 상속받은 클래스에서 사용되어야 한다.
그렇지 않으면 Layout 관련되어 문제가 발생 엉뚱한 화면을 만들어 낸다.




+ Recent posts