QtWidgets and QtCore

junissen9

Junissen

Posted on November 26, 2024

QtWidgets and QtCore

Widgets in GitHub usually focus on making the contact/file quickly accessible upon import. Only in Qt are they equipped with the function of transporting data from Core to visual and .exe.

from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1126, 694)
        MainWindow.setStyleSheet("background-color: rgb(233, 255, 157);")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(30, 30, 441, 31))
        font = QtGui.QFont()
        font.setPointSize(14)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(30, 100, 251, 21))
Enter fullscreen mode Exit fullscreen mode

Unfortunately, it won't be possible to create this artificially, no matter how hard the AI ​​tries. Because the visual doesn't wander from the form to the operating system and it is better to write functions explicitly.

<widget class="QWidget" name="centralwidget">
   <widget class="QLabel" name="label">
    <property name="geometry">
     <rect>
      <x>30</x>
      <y>30</y>
      <width>441</width>
      <height>31</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <pointsize>14</pointsize>
     </font>
    </property>
    <property name="text">
     <string>Select Smart Home options</string>
    </property>
   </widget>
Enter fullscreen mode Exit fullscreen mode

In addition to setting the optimal options, there are a number of features:

  • It is better to separate Gui and Widgets into a separate block, because their features do not affect performance
  • As for connecting to the database/identifiers/libraries, write in every line of code, referencing like this: QtCore.QMetaObject.connectSlotsByName(MainWindow)
  • Ask the file storage to use already implemented MainWindow functions, because it saves time
💖 💪 🙅 🚩
junissen9
Junissen

Posted on November 26, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

QtWidgets and QtCore
tutorial QtWidgets and QtCore

November 26, 2024