Pyqt display drop-down content

Source: Internet
Author: User

#-*-Coding: cp936 -*-

From pyqt4.qtcore import *

From pyqt4.qtgui import *

 

 

 

Class inlineeditor (qwidget ):

 

_ Mute = 'mute'

 

Def _ init _ (self, parent ):

Qwidget. _ init _ (self, parent)

Self. setautofillbackground (true)

Lo = qhboxlayout ()

Lo. setmargin (0)

Lo. setspacing (4)

 

Self. _ cbfoo = qcombobox ()

For X in ["ABC", "def", "Ghi", "jkl"]:

Self. _ cbfoo. additem (X)

 

Self. _ lebar = qlineedit ('', self)

Self. _ lebar. setvalidator (qintvalidator (0, 999999, self ))

 

Lo. addwidget (self. _ cbfoo, 3)

Lo. addspacing (5)

Lo. addwidget (qlabel ('bar :'))

Lo. addwidget (self. _ lebar, 3)

Lo. addstretch (5)

Self. setlayout (LO)

 

Class form (qdialog ):

Def _ init _ (self, parent = none ):

Qdialog. _ init _ (self, parent)

Grid = qgridlayout ()

Tree = qtreewidget ()

Tree. setcolumncount (2)

 

For N in range (3 ):

I = qtreewidgetitem (tree) # create a subproject of qtreewidget I

I. settext (0, "first" + STR (N) # SET THE TEXT OF THE 0th Column

I. settext (1, "second ")

For m in range (3 ):

J = qtreewidgetitem (I) # create a subproject for qtreewidget subproject I

J. settext (0, "Child First" + STR (m ))

 

B1 = qcheckbox ("Push me 0", tree) # note the second parameter here. If this parameter is not created successfully

Tree. setitemwidget (tree. toplevelitem (0). Child (1), 1, B1) # Place the control in Column 2nd of the first sub-project of the first project.

 

Item = inlineeditor (tree) # process the combination of multiple controls

Tree. setitemwidget (tree. toplevelitem (0). Child (1), 1, item)

 

Grid. addwidget (tree)

Self. setlayout (GRID)

 

APP = qapplication ([])

Form = form ()

Form. Show ()

 

App.exe C _()

:

Pyqt display drop-down content

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.