Skip to main content

QDialog with QScrollArea adjustSize on widget hide

File: search.py

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

# Form implementation generated from reading ui file '/home/chris/Documents/papinhio-player/ui/menu-3/radio-stations/search/search.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(837, 556)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/main-window/assets/images/main-window/search.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        Dialog.setWindowIcon(icon)
        Dialog.setStyleSheet("QScrollArea{\n"
"    border:0px;\n"
"}")
        self.gridLayout = QtWidgets.QGridLayout(Dialog)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.scrollArea = QtWidgets.QScrollArea(Dialog)
        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setObjectName("scrollArea")
        self.scrollAreaWidgetContents = QtWidgets.QWidget()
        self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 837, 556))
        self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
        self.verticalLayout.setObjectName("verticalLayout")
        self.search_frame = QtWidgets.QFrame(self.scrollAreaWidgetContents)
        self.search_frame.setStyleSheet("QFrame{\n"
"    border:none;\n"
"}")
        self.search_frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.search_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.search_frame.setObjectName("search_frame")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.search_frame)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.search_phrase = QtWidgets.QLineEdit(self.search_frame)
        self.search_phrase.setObjectName("search_phrase")
        self.horizontalLayout.addWidget(self.search_phrase)
        self.search_button = QtWidgets.QPushButton(self.search_frame)
        self.search_button.setIcon(icon)
        self.search_button.setObjectName("search_button")
        self.horizontalLayout.addWidget(self.search_button)
        self.verticalLayout.addWidget(self.search_frame)
        self.loading_frame = QtWidgets.QFrame(self.scrollAreaWidgetContents)
        self.loading_frame.setStyleSheet("QFrame{\n"
"    border:none;\n"
"}")
        self.loading_frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.loading_frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.loading_frame.setObjectName("loading_frame")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.loading_frame)
        self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        spacerItem = QtWidgets.QSpacerItem(291, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem)
        self.loading_label = QtWidgets.QLabel(self.loading_frame)
        self.loading_label.setMinimumSize(QtCore.QSize(220, 20))
        self.loading_label.setMaximumSize(QtCore.QSize(220, 20))
        self.loading_label.setText("")
        self.loading_label.setObjectName("loading_label")
        self.horizontalLayout_2.addWidget(self.loading_label)
        spacerItem1 = QtWidgets.QSpacerItem(290, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem1)
        self.verticalLayout.addWidget(self.loading_frame)
        self.results_label = QtWidgets.QLabel(self.scrollAreaWidgetContents)
        self.results_label.setStyleSheet("QLabel{\n"
"    font-weight:bold;\n"
"    text-decoration:underline;\n"
"}")
        self.results_label.setAlignment(QtCore.Qt.AlignCenter)
        self.results_label.setObjectName("results_label")
        self.verticalLayout.addWidget(self.results_label)
        self.table = QtWidgets.QTableWidget(self.scrollAreaWidgetContents)
        self.table.setObjectName("table")
        self.table.setColumnCount(3)
        self.table.setRowCount(0)
        item = QtWidgets.QTableWidgetItem()
        self.table.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.table.setHorizontalHeaderItem(1, item)
        item = QtWidgets.QTableWidgetItem()
        self.table.setHorizontalHeaderItem(2, item)
        self.table.horizontalHeader().setCascadingSectionResizes(False)
        self.table.horizontalHeader().setDefaultSectionSize(150)
        self.table.horizontalHeader().setStretchLastSection(True)
        self.verticalLayout.addWidget(self.table)
        self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
        self.label_2.setStyleSheet("QLabel{\n"
"    font-weight:bold;\n"
"    color:green;\n"
"}")
        self.label_2.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter)
        self.label_2.setWordWrap(True)
        self.label_2.setObjectName("label_2")
        self.verticalLayout.addWidget(self.label_2)
        self.ok = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/rest-windows/assets/images/rest-windows/ok.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ok.setIcon(icon1)
        self.ok.setObjectName("ok")
        self.verticalLayout.addWidget(self.ok)
        self.scrollArea.setWidget(self.scrollAreaWidgetContents)
        self.gridLayout.addWidget(self.scrollArea, 0, 0, 1, 1)

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Εύρεση ραδιοφωνικών συνδέσεων"))
        self.search_phrase.setPlaceholderText(_translate("Dialog", "Αναζήτηση βάση τίτλου ραδιοφωνικής σύνδεσης"))
        self.search_button.setText(_translate("Dialog", "Αναζήτηση"))
        self.results_label.setText(_translate("Dialog", "Αποτέλεσμα αναζήτησης: Η αναζήτηση ολοκληρώθηκε επιτυχώς. Βρέθηκαν ... ραδιοφωνικές συνδέσεις"))
        item = self.table.horizontalHeaderItem(0)
        item.setText(_translate("Dialog", "Τίτλος"))
        item = self.table.horizontalHeaderItem(1)
        item.setText(_translate("Dialog", "Radio hostname"))
        item = self.table.horizontalHeaderItem(2)
        item.setText(_translate("Dialog", "Ενέργεια"))
        self.label_2.setText(_translate("Dialog", "Σημείωση 1: Η αναζήτηση πραγματοποιείτε με κριτήριο τον τίτλο των ραδιοφωνικών συνδέσεων.\n"
"Σημείωση 2: Αφήστε κένο πεδίο για εύρεση όλων των ραδιοφωνικών συνδέσεων.\n"
"Σημείωση 3: Η αναζήτηση είναι case insensitive δηλαδή θα πρέπει να δοκιμάσετε και με κεφαλαίους χαρακτήρες εφόσον δεν βρεθούν αποτελέσματα."))
        self.ok.setText(_translate("Dialog", "Εντάξει - Κλείσιμο παραθύρου"))
import sys
sys.path.append('../../../')

#import importlib
#icons = importlib.import_module('compiled-ui.icons')


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())

File: search_support.py

from PyQt5 import QtCore, QtGui, QtWidgets
import search
import sys

class Run_me:

    def __init__(self):
        self.app = QtWidgets.QApplication(sys.argv)
        self.Dialog = QtWidgets.QDialog()
        self.ui = search.Ui_Dialog()
        self.ui.setupUi(self.Dialog)
        self.Dialog.show()
        
        
        self.ui.table.setColumnWidth(0, 350)
        self.ui.table.setColumnWidth(1, 120)
        

        
        self.ui.loading_frame.hide()
        self.ui.table.hide()
        self.ui.results_label.hide()
        
        self.Dialog.adjustSize()
        
        
        self.Dialog.hide()
        self.Dialog.show()
        self.Dialog.update()
        


        sys.exit(self.app.exec_())

if __name__ == "__main__":
    programm = Run_me()

Try to run search_support.py

The result is:

enter image description here

but the desired result is:

enter image description here

How can i adjustSize of QDialog which has inside a QScrollArea? Which size policies should i use?

Here is the search.ui file:

<?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>837</width>
    <height>556</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Εύρεση ραδιοφωνικών συνδέσεων</string>
  </property>
  <property name="windowIcon">
   <iconset>
    <normaloff>:/main-window/assets/images/main-window/search.png</normaloff>:/main-window/assets/images/main-window/search.png</iconset>
  </property>
  <property name="styleSheet">
   <string notr="true">QScrollArea{
    border:0px;
}</string>
  </property>
  <layout class="QGridLayout" name="gridLayout">
   <property name="leftMargin">
    <number>0</number>
   </property>
   <property name="topMargin">
    <number>0</number>
   </property>
   <property name="rightMargin">
    <number>0</number>
   </property>
   <property name="bottomMargin">
    <number>0</number>
   </property>
   <item row="0" column="0">
    <widget class="QScrollArea" name="scrollArea">
     <property name="widgetResizable">
      <bool>true</bool>
     </property>
     <widget class="QWidget" name="scrollAreaWidgetContents">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>837</width>
        <height>556</height>
       </rect>
      </property>
      <layout class="QVBoxLayout" name="verticalLayout">
       <item>
        <widget class="QFrame" name="search_frame">
         <property name="styleSheet">
          <string notr="true">QFrame{
    border:none;
}</string>
         </property>
         <property name="frameShape">
          <enum>QFrame::StyledPanel</enum>
         </property>
         <property name="frameShadow">
          <enum>QFrame::Raised</enum>
         </property>
         <layout class="QHBoxLayout" name="horizontalLayout">
          <property name="leftMargin">
           <number>0</number>
          </property>
          <property name="topMargin">
           <number>0</number>
          </property>
          <property name="rightMargin">
           <number>0</number>
          </property>
          <property name="bottomMargin">
           <number>0</number>
          </property>
          <item>
           <widget class="QLineEdit" name="search_phrase">
            <property name="placeholderText">
             <string>Αναζήτηση βάση τίτλου ραδιοφωνικής σύνδεσης</string>
            </property>
           </widget>
          </item>
          <item>
           <widget class="QPushButton" name="search_button">
            <property name="text">
             <string>Αναζήτηση</string>
            </property>
            <property name="icon">
             <iconset>
              <normaloff>:/main-window/assets/images/main-window/search.png</normaloff>:/main-window/assets/images/main-window/search.png</iconset>
            </property>
           </widget>
          </item>
         </layout>
        </widget>
       </item>
       <item>
        <widget class="QFrame" name="loading_frame">
         <property name="styleSheet">
          <string notr="true">QFrame{
    border:none;
}</string>
         </property>
         <property name="frameShape">
          <enum>QFrame::StyledPanel</enum>
         </property>
         <property name="frameShadow">
          <enum>QFrame::Raised</enum>
         </property>
         <layout class="QHBoxLayout" name="horizontalLayout_2">
          <property name="leftMargin">
           <number>0</number>
          </property>
          <property name="topMargin">
           <number>0</number>
          </property>
          <property name="rightMargin">
           <number>0</number>
          </property>
          <property name="bottomMargin">
           <number>0</number>
          </property>
          <item>
           <spacer name="horizontalSpacer">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
              <width>291</width>
              <height>20</height>
             </size>
            </property>
           </spacer>
          </item>
          <item>
           <widget class="QLabel" name="loading_label">
            <property name="minimumSize">
             <size>
              <width>220</width>
              <height>20</height>
             </size>
            </property>
            <property name="maximumSize">
             <size>
              <width>220</width>
              <height>20</height>
             </size>
            </property>
            <property name="text">
             <string/>
            </property>
           </widget>
          </item>
          <item>
           <spacer name="horizontalSpacer_2">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
            <property name="sizeHint" stdset="0">
             <size>
              <width>290</width>
              <height>20</height>
             </size>
            </property>
           </spacer>
          </item>
         </layout>
        </widget>
       </item>
       <item>
        <widget class="QLabel" name="results_label">
         <property name="styleSheet">
          <string notr="true">QLabel{
    font-weight:bold;
    text-decoration:underline;
}</string>
         </property>
         <property name="text">
          <string>Αποτέλεσμα αναζήτησης: Η αναζήτηση ολοκληρώθηκε επιτυχώς. Βρέθηκαν ... ραδιοφωνικές συνδέσεις</string>
         </property>
         <property name="alignment">
          <set>Qt::AlignCenter</set>
         </property>
        </widget>
       </item>
       <item>
        <widget class="QTableWidget" name="table">
         <attribute name="horizontalHeaderCascadingSectionResizes">
          <bool>false</bool>
         </attribute>
         <attribute name="horizontalHeaderDefaultSectionSize">
          <number>150</number>
         </attribute>
         <attribute name="horizontalHeaderStretchLastSection">
          <bool>true</bool>
         </attribute>
         <column>
          <property name="text">
           <string>Τίτλος</string>
          </property>
         </column>
         <column>
          <property name="text">
           <string>Radio hostname</string>
          </property>
         </column>
         <column>
          <property name="text">
           <string>Ενέργεια</string>
          </property>
         </column>
        </widget>
       </item>
       <item>
        <widget class="QLabel" name="label_2">
         <property name="styleSheet">
          <string notr="true">QLabel{
    font-weight:bold;
    color:green;
}</string>
         </property>
         <property name="text">
          <string>Σημείωση 1: Η αναζήτηση πραγματοποιείτε με κριτήριο τον τίτλο των ραδιοφωνικών συνδέσεων.
Σημείωση 2: Αφήστε κένο πεδίο για εύρεση όλων των ραδιοφωνικών συνδέσεων.
Σημείωση 3: Η αναζήτηση είναι case insensitive δηλαδή θα πρέπει να δοκιμάσετε και με κεφαλαίους χαρακτήρες εφόσον δεν βρεθούν αποτελέσματα.</string>
         </property>
         <property name="alignment">
          <set>Qt::AlignJustify|Qt::AlignVCenter</set>
         </property>
         <property name="wordWrap">
          <bool>true</bool>
         </property>
        </widget>
       </item>
       <item>
        <widget class="QPushButton" name="ok">
         <property name="text">
          <string>Εντάξει - Κλείσιμο παραθύρου</string>
         </property>
         <property name="icon">
          <iconset>
           <normaloff>:/rest-windows/assets/images/rest-windows/ok.png</normaloff>:/rest-windows/assets/images/rest-windows/ok.png</iconset>
         </property>
        </widget>
       </item>
      </layout>
     </widget>
    </widget>
   </item>
  </layout>
 </widget>
 <resources/>
 <connections/>
</ui>



source https://stackoverflow.com/questions/71161978/qdialog-with-qscrollarea-adjustsize-on-widget-hide

Comments

Popular posts from this blog

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console...

How to split a rinex file if I need 24 hours data

Trying to divide rinex file using the command gfzrnx but getting this error. While doing that getting this error msg 'gfzrnx' is not recognized as an internal or external command Trying to split rinex file using the command gfzrnx. also install'gfzrnx'. my doubt is I need to run this program in 'gfzrnx' or in 'cmdprompt'. I am expecting a rinex file with 24 hrs or 1 day data.I Have 48 hrs data in RINEX format. Please help me to solve this issue. source https://stackoverflow.com/questions/75385367/how-to-split-a-rinex-file-if-i-need-24-hours-data