久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='VO6Ep'></tfoot>
  • <legend id='VO6Ep'><style id='VO6Ep'><dir id='VO6Ep'><q id='VO6Ep'></q></dir></style></legend>
    <i id='VO6Ep'><tr id='VO6Ep'><dt id='VO6Ep'><q id='VO6Ep'><span id='VO6Ep'><b id='VO6Ep'><form id='VO6Ep'><ins id='VO6Ep'></ins><ul id='VO6Ep'></ul><sub id='VO6Ep'></sub></form><legend id='VO6Ep'></legend><bdo id='VO6Ep'><pre id='VO6Ep'><center id='VO6Ep'></center></pre></bdo></b><th id='VO6Ep'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VO6Ep'><tfoot id='VO6Ep'></tfoot><dl id='VO6Ep'><fieldset id='VO6Ep'></fieldset></dl></div>

    1. <small id='VO6Ep'></small><noframes id='VO6Ep'>

      • <bdo id='VO6Ep'></bdo><ul id='VO6Ep'></ul>
      1. 使用 QComboBox 選擇顯示的不同小部件集

        Using QComboBox to select different set of widgets displayed(使用 QComboBox 選擇顯示的不同小部件集)
        <tfoot id='x1mwW'></tfoot>
          <i id='x1mwW'><tr id='x1mwW'><dt id='x1mwW'><q id='x1mwW'><span id='x1mwW'><b id='x1mwW'><form id='x1mwW'><ins id='x1mwW'></ins><ul id='x1mwW'></ul><sub id='x1mwW'></sub></form><legend id='x1mwW'></legend><bdo id='x1mwW'><pre id='x1mwW'><center id='x1mwW'></center></pre></bdo></b><th id='x1mwW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='x1mwW'><tfoot id='x1mwW'></tfoot><dl id='x1mwW'><fieldset id='x1mwW'></fieldset></dl></div>

              <bdo id='x1mwW'></bdo><ul id='x1mwW'></ul>
                  <tbody id='x1mwW'></tbody>
              1. <legend id='x1mwW'><style id='x1mwW'><dir id='x1mwW'><q id='x1mwW'></q></dir></style></legend>
              2. <small id='x1mwW'></small><noframes id='x1mwW'>

                • 本文介紹了使用 QComboBox 選擇顯示的不同小部件集的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用左側工具欄的圖像查看器.由于我有很多措施要做,但想將大部分顯示用于圖片并保持工具欄薄,我想使用 combo_box1combo_box2 來選擇不同的工具欄中顯示的小部件.

                  I'm working on an image viewer with a toolbar on the left. As I have many measures to make but want to use most of the display for the picture and keep the toolbar thin, I would like to use combo_box1 and combo_box2 to select the different widgets displayed in the toolbar.

                  示例 1: 如果我在 combo_box1 中選擇 measurements set 1 我就可以在 P1-P2 測量之間進行選擇combo_box2 中的 P3-P4.

                  Example 1: if I choose measurements set 1 in combo_box1 I would then be able to choose between measurements P1-P2 and P3-P4 in combo_box2.

                  示例 2: 如果我在 combo_box1 中選擇 measurements set 2,我就可以在測量值 P5-P6 之間進行選擇combo_box2 中的 P7-P8.

                  Example 2: if I choose measurements set 2 in combo_box1 I would then be able to choose between measurements P5-P6 and P7-P8 in combo_box2.

                  代碼如下:

                  from PySide2.QtWidgets import (QWidget, QApplication, QGraphicsView, QGridLayout)
                  from PySide2 import QtCore, QtWidgets, QtGui
                  from PySide2.QtOpenGL import *
                  from PySide2.QtCore import *
                  from PySide2.QtGui import *
                  
                  image_path_str='image.jpg'
                  
                  class View(QGraphicsView):
                      photo_clicked = QtCore.Signal(QtCore.QPoint)
                  
                      def __init__(self, parent):
                          super(View, self).__init__()
                          self.scene = QtWidgets.QGraphicsScene(self)
                          self.photo = QtWidgets.QGraphicsPixmapItem()
                          self.scene.addItem(self.photo)
                          self.pixmap = QtGui.QPixmap(image_path_str)
                          self.photo.setPixmap(self.pixmap)
                          self.setScene(self.scene)
                          self.setDragMode(QGraphicsView.ScrollHandDrag)
                  
                  class Window(QWidget):
                      def __init__(self):
                          super(Window, self).__init__()
                          self.view = View(self)
                  
                          self.layout_contain_P1_P2 = QtWidgets.QGridLayout()
                          self.checkbox_P1= QtWidgets.QCheckBox("P1",self)
                          self.line_edit_P1_x = QtWidgets.QLineEdit(self)
                          self.line_edit_P1_x.setReadOnly(True)
                          self.line_edit_P1_y = QtWidgets.QLineEdit(self)
                          self.line_edit_P1_y.setReadOnly(True)
                  
                          self.layout_contain_P1_P2.addWidget(self.checkbox_P1, 0, 0, Qt.AlignLeft)
                  
                          self.grid_layout_P1_x_y = QtWidgets.QGridLayout()
                          self.grid_layout_P1_x_y.addWidget(self.line_edit_P1_x, 1, 0, Qt.AlignLeft)
                          self.grid_layout_P1_x_y.addWidget(self.line_edit_P1_y, 2, 0, Qt.AlignLeft)
                  
                          self.layout_contain_P1_P2.addLayout(self.grid_layout_P1_x_y, 0, 1, 1, 1)
                          self.checkbox_P2 = QtWidgets.QCheckBox("P2",self)
                          self.line_edit_P2_x = QtWidgets.QLineEdit(self)
                          self.line_edit_P2_x.setReadOnly(True)
                          self.line_edit_P2_y = QtWidgets.QLineEdit(self)
                          self.line_edit_P2_y.setReadOnly(True)
                  
                          self.layout_contain_P1_P2.addWidget(self.checkbox_P2, 1, 0, Qt.AlignLeft)
                          self.grid_layout_P2_x_y = QtWidgets.QGridLayout()
                  
                          self.grid_layout_P2_x_y.addWidget(self.line_edit_P2_x, 0, 0, Qt.AlignLeft)
                          self.grid_layout_P2_x_y.addWidget(self.line_edit_P2_y, 1, 0, Qt.AlignLeft)
                  
                          self.layout_contain_P1_P2.addLayout(self.grid_layout_P2_x_y, 1, 1, Qt.AlignLeft)
                  
                          self.combo_box1 = QtWidgets.QComboBox(self)
                          self.combo_box1.addItem("measurements set 1")
                          self.combo_box1.addItem("measurements set 1")
                  
                          self.combo_box2 = QtWidgets.QComboBox(self)
                          self.combo_box2.addItem("P1-P2")
                          self.combo_box2.addItem("P3-P4")
                  
                          self.vertical1= QtWidgets.QVBoxLayout()
                  
                          self.vertical1.addWidget(self.combo_box1)
                          self.vertical1.addWidget(self.combo_box2)
                          self.vertical1.addLayout(self.layout_contain_P1_P2)
                  
                          self.vertical2= QtWidgets.QVBoxLayout()
                          self.vertical2.addWidget(self.view)
                  
                          self.horizontal= QtWidgets.QHBoxLayout()
                          self.horizontal.addLayout(self.vertical1)
                          self.horizontal.addLayout(self.vertical2)
                  
                          self.setLayout(self.horizontal)
                          self.setWindowTitle("Image viewer")
                          self.setGeometry(200, 200, 1000, 800)
                  
                  app = QApplication.instance()
                  if app is None:
                          app = QApplication([])
                  w = Window()
                  w.show()
                  w.raise_()
                  QApplication.setOverrideCursor(QCursor(Qt.CrossCursor))
                  app.exec_()
                  

                  推薦答案

                  如果你分析你的邏輯,你可以看到數據有樹的結構:

                  If you analyze your logic, you can see that the data has the structure of a tree:

                  root
                  ├── measurements set 1
                  │?? ├── P1-P2
                  │?? └── P3-P4
                  └── measurements set 2
                      ├── P5-P6
                      └── P7-P8
                  

                  所以將使用 QComboBox 支持作為模型的信息源,并確定使用哪個表顯示 rootModelIndex,在下一部分中,我將創建一個涉及 QComboBox 加上另外一個級別定義的除了觀察依賴之外會使用一個QTreeView.

                  import sys
                  
                  from PySide2.QtWidgets import *
                  from PySide2.QtGui import *
                  
                  class Widget(QWidget):
                      def __init__(self, parent=None):
                          QWidget.__init__(self, parent)
                          play = QVBoxLayout(self)
                          lay = QHBoxLayout()
                          self.model = create_model(d)
                  
                          self.treeView = QTreeView()
                          play.addLayout(lay)
                          play.addWidget(self.treeView)
                          self.treeView.setModel(self.model)
                          self.treeView.expandAll()
                  
                          ix = self.model.index(0, 0)
                          self.combos = []
                          while self.model.hasChildren(ix):
                              combo = QComboBox()
                              combo.setModel(self.model)
                              lay.addWidget(combo)
                              combo.setRootModelIndex(ix)
                              combo.setCurrentIndex(0)
                              ix = ix.child(0, 0)
                              combo.currentIndexChanged.connect(self.on_currentIndexChanged)
                              self.combos.append(combo)
                  
                      def next_combo(self, combo):
                          ix = self.combos.index(combo)
                          if ix != len(self.combos)-1:
                              return self.combos[ix+1]
                  
                  
                      def on_currentIndexChanged(self, index):
                          combo = self.sender()
                          combo_child = self.next_combo(combo)
                          if combo_child:
                              p_ix = combo.rootModelIndex()
                              ix = p_ix.child(index, 0)
                              combo_child.setRootModelIndex(ix)
                              combo_child.setCurrentIndex(0)
                  
                  
                  def load_childrens(values, parent):
                      for value in values:
                          name = value["name"]
                          dependencies = value["dependencies"]
                          item = QStandardItem(name)
                          parent.appendRow(item)
                          load_childrens(dependencies, item)
                  
                  def create_model(info):
                      model = QStandardItemModel()
                      root = QStandardItem("root")
                      model.appendRow(root)
                      load_childrens(info, root)
                      return model
                  
                  
                  d = [{
                          'name': 'measurements set 1',
                          'dependencies': [
                              {
                                  'name': 'P1-P2',
                                  'dependencies': [
                                  {
                                      'name': "T1",
                                      "dependencies" : []
                                  },
                                  {
                                      'name': "T2",
                                      "dependencies" : []
                                  }
                                  ]
                              },
                              {
                                  'name': 'P3-P4',
                                  'dependencies': [
                                  {
                                      'name': "T3",
                                      "dependencies" : []
                                  },
                                  {
                                      'name': "T4",
                                      "dependencies" : []
                                  }
                  
                                  ]
                              }
                          ],
                      },
                      {
                          'name': 'measurements set 2',
                          'dependencies': [
                              {
                                  'name': 'P5-P6',
                                  'dependencies': [
                                  {
                                      'name': "T5",
                                      "dependencies" : []
                                  },
                                  {
                                      'name': "T6",
                                      "dependencies" : []
                                  }
                                  ]
                              },
                              {
                                  'name': 'P7-P8',
                                  'dependencies': [
                                  {
                                      'name': "T7",
                                      "dependencies" : []
                                  },
                                  {
                                      'name': "T8",
                                      "dependencies" : []
                                  }
                                  ]
                              }
                          ],
                      }]
                  
                  if __name__ == '__main__':
                      app = QApplication(sys.argv)
                      w = Widget()
                      w.show()
                      sys.exit(app.exec_())
                  

                  在您的情況下,代碼如下:

                  In your case, the code is the following:

                  from PySide2.QtWidgets import QWidget, QApplication, QGraphicsView, QGridLayout, QComboBox, 
                       QGraphicsScene, QGraphicsPixmapItem, QCheckBox, QLineEdit, QVBoxLayout, QHBoxLayout
                  from PySide2.QtCore import Signal, QPoint, Qt
                  from PySide2.QtGui import QPixmap, QStandardItemModel, QStandardItem, QCursor
                  
                  image_path_str='image.jpg'
                  
                  class View(QGraphicsView):
                      photo_clicked = Signal(QPoint)
                  
                      def __init__(self, parent):
                          super(View, self).__init__()
                          self.scene = QGraphicsScene(self)
                          self.photo = QGraphicsPixmapItem()
                          self.scene.addItem(self.photo)
                          self.pixmap = QPixmap(image_path_str)
                          self.photo.setPixmap(self.pixmap)
                          self.setScene(self.scene)
                          self.setDragMode(QGraphicsView.ScrollHandDrag)
                  
                  class Window(QWidget):
                      def __init__(self):
                          super(Window, self).__init__()
                          self.view = View(self)
                  
                          self.layout_contain_P1_P2 = QGridLayout()
                          self.checkbox_P1= QCheckBox("P1",self)
                          self.line_edit_P1_x = QLineEdit(self)
                          self.line_edit_P1_x.setReadOnly(True)
                          self.line_edit_P1_y = QLineEdit(self)
                          self.line_edit_P1_y.setReadOnly(True)
                  
                          self.layout_contain_P1_P2.addWidget(self.checkbox_P1, 0, 0, Qt.AlignLeft)
                  
                          self.grid_layout_P1_x_y = QGridLayout()
                          self.grid_layout_P1_x_y.addWidget(self.line_edit_P1_x, 1, 0, Qt.AlignLeft)
                          self.grid_layout_P1_x_y.addWidget(self.line_edit_P1_y, 2, 0, Qt.AlignLeft)
                  
                          self.layout_contain_P1_P2.addLayout(self.grid_layout_P1_x_y, 0, 1, 1, 1)
                          self.checkbox_P2 = QCheckBox("P2",self)
                          self.line_edit_P2_x = QLineEdit(self)
                          self.line_edit_P2_x.setReadOnly(True)
                          self.line_edit_P2_y = QLineEdit(self)
                          self.line_edit_P2_y.setReadOnly(True)
                  
                          self.layout_contain_P1_P2.addWidget(self.checkbox_P2, 1, 0, Qt.AlignLeft)
                          self.grid_layout_P2_x_y = QGridLayout()
                  
                          self.grid_layout_P2_x_y.addWidget(self.line_edit_P2_x, 0, 0, Qt.AlignLeft)
                          self.grid_layout_P2_x_y.addWidget(self.line_edit_P2_y, 1, 0, Qt.AlignLeft)
                  
                          self.layout_contain_P1_P2.addLayout(self.grid_layout_P2_x_y, 1, 1, Qt.AlignLeft)
                  
                          self.vertical1= QVBoxLayout()
                  
                          self.model = create_model(d)
                          ix = self.model.index(0, 0)
                          self.combos = []
                          while self.model.hasChildren(ix):
                              combo = QComboBox()
                              combo.setModel(self.model)
                              self.vertical1.addWidget(combo)
                              combo.setRootModelIndex(ix)
                              combo.setCurrentIndex(0)
                              ix = ix.child(0, 0)
                              combo.currentIndexChanged.connect(self.on_currentIndexChanged)
                              self.combos.append(combo)
                  
                          self.vertical1.addLayout(self.layout_contain_P1_P2)
                  
                          self.vertical2= QVBoxLayout()
                          self.vertical2.addWidget(self.view)
                  
                          self.horizontal= QHBoxLayout()
                          self.horizontal.addLayout(self.vertical1)
                          self.horizontal.addLayout(self.vertical2)
                  
                          self.setLayout(self.horizontal)
                          self.setWindowTitle("Image viewer")
                          self.setGeometry(200, 200, 1000, 800)
                  
                      def next_combo(self, combo):
                          ix = self.combos.index(combo)
                          if ix != len(self.combos)-1:
                              return self.combos[ix+1]
                  
                      def on_currentIndexChanged(self, index):
                          combo = self.sender()
                          combo_child = self.next_combo(combo)
                          if combo_child:
                              p_ix = combo.rootModelIndex()
                              ix = p_ix.child(index, 0)
                              combo_child.setRootModelIndex(ix)
                              combo_child.setCurrentIndex(0)
                  
                  def load_childrens(values, parent):
                      for value in values:
                          name = value["name"]
                          dependencies = value["dependencies"]
                          item = QStandardItem(name)
                          parent.appendRow(item)
                          load_childrens(dependencies, item)
                  
                  def create_model(info):
                      model = QStandardItemModel()
                      root = QStandardItem("root")
                      model.appendRow(root)
                      load_childrens(info, root)
                      return model
                  
                  
                  d = [{
                          'name': 'measurements set 1',
                          'dependencies': [
                              {
                                  'name': 'P1-P2',
                                  'dependencies': []
                              },
                              {
                                  'name': 'P3-P4',
                                  'dependencies': []
                              }
                          ],
                      },
                      {
                          'name': 'measurements set 2',
                          'dependencies': [
                              {
                                  'name': 'P5-P6',
                                  'dependencies': []
                              },
                              {
                                  'name': 'P7-P8',
                                  'dependencies': []
                              }
                          ],
                      }]
                  
                  if __name__ == '__main__':
                      import sys
                  
                      app = QApplication(sys.argv)
                      w = Window()
                      w.show()
                      app.setOverrideCursor(QCursor(Qt.CrossCursor))
                      sys.exit(app.exec_())
                  

                  這篇關于使用 QComboBox 選擇顯示的不同小部件集的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)

                      <tfoot id='6Rj82'></tfoot>

                      <i id='6Rj82'><tr id='6Rj82'><dt id='6Rj82'><q id='6Rj82'><span id='6Rj82'><b id='6Rj82'><form id='6Rj82'><ins id='6Rj82'></ins><ul id='6Rj82'></ul><sub id='6Rj82'></sub></form><legend id='6Rj82'></legend><bdo id='6Rj82'><pre id='6Rj82'><center id='6Rj82'></center></pre></bdo></b><th id='6Rj82'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='6Rj82'><tfoot id='6Rj82'></tfoot><dl id='6Rj82'><fieldset id='6Rj82'></fieldset></dl></div>

                      <small id='6Rj82'></small><noframes id='6Rj82'>

                      • <legend id='6Rj82'><style id='6Rj82'><dir id='6Rj82'><q id='6Rj82'></q></dir></style></legend>

                            <tbody id='6Rj82'></tbody>
                            <bdo id='6Rj82'></bdo><ul id='6Rj82'></ul>

                            主站蜘蛛池模板: 亚洲精品一区二区久 | 久久一区二区三区四区 | 亚洲国产一区二区视频 | 国产一区h| 欧美日韩三区 | 国产精品视频在线观看 | 午夜丰满寂寞少妇精品 | 亚洲狠狠| 国产超碰人人爽人人做人人爱 | 久久久久九九九女人毛片 | 国产精品视频一区二区三区 | 激情黄色在线观看 | 国产精品久久久久久婷婷天堂 | 在线观看电影av | jlzzjlzz国产精品久久 | 国外激情av | 天天操,夜夜爽 | 男女视频网站 | 国产一区二 | 国产一区二区三区在线 | 国产一区二区三区精品久久久 | 中文字幕综合 | 日韩精品一区二区三区中文在线 | 做a视频| 黄色毛片免费视频 | 亚洲欧美综合 | 91精品国产综合久久婷婷香蕉 | 欧美三级电影在线播放 | 成人欧美一区二区三区黑人孕妇 | 黄色在线观看网站 | 久久久不卡网国产精品一区 | 99精品视频一区二区三区 | 久久久精品一区二区三区 | 这里只有精品99re | 精品国产欧美一区二区 | av在线一区二区三区 | 日韩在线中文 | 久久久久精 | 污污的网站在线观看 | 久久精品性视频 | 麻豆精品国产91久久久久久 |