|
0 / 0 / 0
Регистрация: 24.10.2015
Сообщений: 142
|
|||||||||||
PyQt5 В comboBox вывести пустое значение07.08.2022, 13:22. Показов 1906. Ответов 2
Метки нет (Все метки)
Форумчане, привет!
Работаю с формой. Ввожу в поля QLineEdit значения. В конце обработки нажимаю кнопку ОК (Button_4), при нажатии которой сохраняется файл json с данными. При этом я хочу так же очистить значения во всех полях, чтобы можно было выполнить следующий замер / расчет. Поля QLineEdit очищаю записью пустышки ''. Необходимо, так же очистить значение поля comboBox. Попробовал очистить его с помощью self.comboBox.clear() - получилось, но при вводе новых данных в combobox полностью пропадают значения для выбора. Они появляются только при перезапуске программы. В итоге, необходимо очистить значение в combobox установкой в нем первого из этих трех значений:
Подскажите, пожалуйста, как это сделать? Благодарю. Мой код:
На всякий случай, для тестирования код Test.ui: Кликните здесь для просмотра всего текста
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>Dialog</class> <widget class="QDialog" name="Dialog"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>591</width> <height>231</height> </rect> </property> <property name="windowTitle"> <string>Dialog</string> </property> <property name="toolTip"> <string><html><head/><body><p align="center"><br/></p></body></html></string> </property> <property name="styleSheet"> <string notr="true">background-color: rgb(212, 212, 212);</string> </property> <widget class="QTextEdit" name="textEdit"> <property name="geometry"> <rect> <x>10</x> <y>140</y> <width>571</width> <height>51</height> </rect> </property> <property name="styleSheet"> <string notr="true">background-color: rgb(255, 255, 255);</string> </property> <property name="html"> <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html4... "> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string> </property> </widget> <widget class="QLabel" name="label_5"> <property name="geometry"> <rect> <x>10</x> <y>60</y> <width>71</width> <height>31</height> </rect> </property> <property name="text"> <string><html><head/><body><p><span style=" font-size:12pt;">Делитель</span></p></body></html></string> </property> </widget> <widget class="QPushButton" name="pushButton"> <property name="geometry"> <rect> <x>90</x> <y>60</y> <width>75</width> <height>23</height> </rect> </property> <property name="toolTip"> <string><html><head/><body><p align="center"><span style=" font-size:12pt;"><br/></span></p></body></html></string> </property> <property name="styleSheet"> <string notr="true">font: 12pt "MS Shell Dlg 2"; background-color: rgb(172, 172, 172);</string> </property> <property name="text"> <string>1:1</string> </property> </widget> <widget class="QPushButton" name="pushButton_2"> <property name="geometry"> <rect> <x>170</x> <y>60</y> <width>75</width> <height>23</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 12pt "MS Shell Dlg 2"; background-color: rgb(172, 172, 172);</string> </property> <property name="text"> <string>1:10</string> </property> </widget> <widget class="QPushButton" name="pushButton_3"> <property name="geometry"> <rect> <x>250</x> <y>60</y> <width>75</width> <height>23</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 12pt "MS Shell Dlg 2"; background-color: rgb(172, 172, 172);</string> </property> <property name="text"> <string>1:100</string> </property> </widget> <widget class="QLabel" name="label_6"> <property name="geometry"> <rect> <x>10</x> <y>100</y> <width>161</width> <height>31</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 10pt "Calibri";</string> </property> <property name="text"> <string><html><head/><body><p align="center"><span style=" font-size:16pt;">Дополнительно:</span></p></body></html></string> </property> </widget> <widget class="QPushButton" name="pushButton_4"> <property name="geometry"> <rect> <x>500</x> <y>200</y> <width>75</width> <height>23</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 12pt "MS Shell Dlg 2"; background-color: rgb(236, 236, 236);</string> </property> <property name="text"> <string>OK</string> </property> </widget> <widget class="QLabel" name="label_4"> <property name="geometry"> <rect> <x>420</x> <y>30</y> <width>31</width> <height>21</height> </rect> </property> <property name="text"> <string><html><head/><body><p><span style=" font-size:12pt;">I, A</span></p></body></html></string> </property> </widget> <widget class="QLabel" name="label_7"> <property name="geometry"> <rect> <x>460</x> <y>0</y> <width>131</width> <height>20</height> </rect> </property> <property name="text"> <string><html><head/><body><p><span style=" font-size:9pt;">9/07/2022 13:30:28</span></p></body></html></string> </property> </widget> <widget class="QLineEdit" name="lineEdit"> <property name="geometry"> <rect> <x>170</x> <y>30</y> <width>51</width> <height>20</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 12pt "Calibri"; background-color: rgb(255, 255, 255);</string> </property> <property name="text"> <string/> </property> </widget> <widget class="QLineEdit" name="lineEdit_2"> <property name="geometry"> <rect> <x>270</x> <y>30</y> <width>41</width> <height>20</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 12pt "Calibri"; background-color: rgb(255, 255, 255);</string> </property> <property name="text"> <string/> </property> </widget> <widget class="QLineEdit" name="lineEdit_3"> <property name="geometry"> <rect> <x>370</x> <y>30</y> <width>41</width> <height>20</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 12pt "Calibri"; background-color: rgb(255, 255, 255);</string> </property> <property name="text"> <string/> </property> </widget> <widget class="QLineEdit" name="lineEdit_4"> <property name="geometry"> <rect> <x>460</x> <y>30</y> <width>41</width> <height>20</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 12pt "Calibri"; background-color: rgb(255, 255, 255);</string> </property> <property name="text"> <string/> </property> </widget> <widget class="QComboBox" name="comboBox"> <property name="geometry"> <rect> <x>20</x> <y>30</y> <width>69</width> <height>22</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 12pt "Calibri"; background-color: rgb(255, 255, 255);</string> </property> </widget> <widget class="QLabel" name="label_2"> <property name="geometry"> <rect> <x>230</x> <y>30</y> <width>41</width> <height>21</height> </rect> </property> <property name="text"> <string><html><head/><body><p><span style=" font-size:12pt;">U, В</span></p></body></html></string> </property> </widget> <widget class="QLabel" name="label_3"> <property name="geometry"> <rect> <x>320</x> <y>30</y> <width>41</width> <height>21</height> </rect> </property> <property name="text"> <string><html><head/><body><p><span style=" font-size:12pt;">R, Ом</span></p></body></html></string> </property> </widget> <widget class="QLabel" name="label"> <property name="geometry"> <rect> <x>110</x> <y>30</y> <width>51</width> <height>21</height> </rect> </property> <property name="styleSheet"> <string notr="true">font: 10pt "Calibri";</string> </property> <property name="text"> <string><html><head/><body><p><span style=" font-size:12pt;">Замер</span></p></body></html></string> </property> </widget> </widget> <resources/> <connections/> </ui>
0
|
|||||||||||
| 07.08.2022, 13:22 | |
|
Ответы с готовыми решениями:
2
Начальное пустое значение в ComboBox
Как занести пустое значение из combobox |
|
19530 / 11067 / 2931
Регистрация: 21.10.2017
Сообщений: 23,294
|
||||||
| 07.08.2022, 13:39 | ||||||
Сообщение было отмечено MaxGal как решение
Решение
MaxGal, надо чтоб выбор комбобокса опять на первую строчку встал чтоли? Или то, что было выбрано удалялось из списка?
Добавлено через 1 минуту
1
|
||||||
|
0 / 0 / 0
Регистрация: 24.10.2015
Сообщений: 142
|
|
| 07.08.2022, 13:55 [ТС] | |
|
iSmokeJC, на первую строчку.
Благодарю. Это именно то, что нужно. Добавлено через 1 минуту Я пробовал ставить не Index, а Item...
0
|
|
| 07.08.2022, 13:55 | |
|
Помогаю со студенческими работами здесь
3
Вывести последнее не пустое значение Если данные в поле не существует вывести пустое значение Убрать пустое поле в comboBox Как вывести значение из бд в combobox? Вывести в comboBox значение из DataTable Искать еще темы с ответами Или воспользуйтесь поиском по форуму: |
|
Новые блоги и статьи
|
|||
|
делаю науч статью по влиянию грибов на сукцессию
anaschu 13.03.2026
прикрепляю статью
|
SDL3 для Desktop (MinGW): Создаём пустое окно с нуля для 2D-графики на SDL3, Си и C++
8Observer8 10.03.2026
Содержание блога
Финальные проекты на Си и на C++:
hello-sdl3-c. zip
hello-sdl3-cpp. zip
Результат:
|
Установка CMake и MinGW 13.1 для сборки С и C++ приложений из консоли и из Qt Creator в EXE
8Observer8 10.03.2026
Содержание блога
MinGW - это коллекция инструментов для сборки приложений в EXE. CMake - это система сборки приложений. Здесь описаны базовые шаги для старта программирования с помощью CMake и. . .
|
Как дизайн сайта влияет на конверсию: 7 решений, которые реально повышают заявки
Neotwalker 08.03.2026
Многие до сих пор воспринимают дизайн сайта как “красивую оболочку”. На практике всё иначе: дизайн напрямую влияет на то, оставит человек заявку или уйдёт через несколько секунд.
Даже если у вас. . .
|
|
Модульная разработка через nuget packages
DevAlt 07.03.2026
Сложившийся в . Net-среде способ разработки чаще всего предполагает
монорепозиторий в котором находятся все исходники.
При создании нового решения, мы просто добавляем нужные проекты
и имеем. . .
|
Модульный подход на примере F#
DevAlt 06.03.2026
В блоге дяди Боба наткнулся на такое определение:
В этой книге («Подход, основанный на вариантах использования») Ивар утверждает,
что архитектура программного обеспечения — это
структуры,. . .
|
Управление камерой с помощью скрипта OrbitControls.js на Three.js: Вращение, зум и панорамирование
8Observer8 05.03.2026
Содержание блога
Финальная демка в браузере работает на Desktop и мобильных браузерах. Итоговый код: orbit-controls-threejs-js. zip. Сканируйте QR-код на мобильном. Вращайте камеру одним пальцем,. . .
|
SDL3 для Web (WebAssembly): Синхронизация спрайтов SDL3 и тел Box2D
8Observer8 04.03.2026
Содержание блога
Финальная демка в браузере. Итоговый код: finish-sync-physics-sprites-sdl3-c. zip
На первой гифке отладочные линии отключены, а на второй включены:. . .
|