Solved QDialog in Windows haven't icon in taskbar
-
Hi!
QDialog in Windows haven't icon in taskbar.
How I can set icon in taskbar for QDialof? -
Hi,
It depends on how you use it.
Show your code.
-
I use this functioin, when all windows hiden:
def dialogRegistrationFunction(self): #Авторизация self.dialogRegistration = QDialog(self) self.dialogRegistration.setWindowModality(QtCore.Qt.ApplicationModal) self.dialogRegistration.setWindowTitle("Авторизация") self.dialogRegistration.setWindowFlag(QtCore.Qt.FramelessWindowHint) self.dialogRegistration.setFixedWidth(420) self.dialogRegistration.setMinimumHeight(520) self.initStyleSheetToObject(self.dialogRegistration) styleSheet = self.dialogRegistration.styleSheet() styleSheet += "; background-color: rgb(16,40,84); border-image: url(./images/Fon2.png) stretch;" self.dialogRegistration.setStyleSheet(styleSheet) styleSheet.replace("; background-color: rgb(16,40,84); border-image: url(./images/Fon2.png) stretch;", "") self.adminPanel.krbTicket = self.getKrbTicket() lineEditName = QLineEdit() lineEditName.setPlaceholderText("Имя") lineEditName.setFixedWidth(250) lineEditName.setStyleSheet("background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch; font: 15;") lineEditPassword = QLineEdit() lineEditPassword.setPlaceholderText("Пароль") lineEditPassword.setFixedWidth(lineEditName.width()) lineEditPassword.setEchoMode(QLineEdit.Password) lineEditPassword.setStyleSheet("background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch; font: 15;") checkBox = QCheckBox() checkBox.setText("Показать пароль") checkBox.setStyleSheet( "background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch; ") def onCheckBoxStateChanged(state): if state == 0: lineEditPassword.setEchoMode(QLineEdit.Password) else: lineEditPassword.setEchoMode(QLineEdit.Normal) checkBox.stateChanged.connect(onCheckBoxStateChanged) self.flagEnterDomainUser = False def onPushButtonDomainUserClicked(): self.dialogRegistration.hide() self.flagEnterDomainUser = self.enterDomainUser() pushButtonDomainUser = QPushButton() pushButtonDomainUser.setStyleSheet("background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch;") pushButtonDomainUser.setText("Войти как доменный пользователь") fontButtonDomainUser = QFont() fontButtonDomainUser.setPixelSize(12) pushButtonDomainUser.setFont(fontButtonDomainUser) pushButtonDomainUser.clicked.connect(onPushButtonDomainUserClicked) if self.adminPanel.krbTicket == None: pushButtonDomainUser.hide() buttonBox = QDialogButtonBox() buttonBox.setCenterButtons(True) # buttonBox.setStyleSheet(styleSheet) buttonBox.setStyleSheet("background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch;") buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonBox.button(QDialogButtonBox.Ok).setText("Войти") # buttonBox.button(QDialogButtonBox.Ok).setText(" ") buttonBox.button(QDialogButtonBox.Cancel).setText("Отмена") buttonBox.accepted.connect(self.dialogRegistration.accept) buttonBox.rejected.connect(self.dialogRegistration.reject) buttonBox.button(QDialogButtonBox.Ok).setStyleSheet( ";background-color: rgb(0,155,221); border-image: url(./images/________.png) stretch; ") buttonBox.button(QDialogButtonBox.Cancel).setStyleSheet( ";background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch; ") fontButton = QFont() fontButton.setPixelSize(17) widthButton = 110 buttonBox.button(QDialogButtonBox.Ok).setFont(fontButton) buttonBox.button(QDialogButtonBox.Cancel).setFont(fontButton) buttonBox.button(QDialogButtonBox.Ok).setFixedWidth(widthButton) buttonBox.button(QDialogButtonBox.Cancel).setFixedWidth(widthButton) buttonBox.button(QDialogButtonBox.Ok).setIcon(QIcon("")) buttonBox.button(QDialogButtonBox.Cancel).setIcon(QIcon("")) fontLineEdit = QFont() fontLineEdit.setPixelSize(17) lineEditName.setFont(fontLineEdit) lineEditPassword.setFont(fontLineEdit) # layout = QFormLayout() layoutY = QVBoxLayout() layoutY.addSpacing(380) hLayout1 = QHBoxLayout() spacing1 = int((self.dialogRegistration.width() - lineEditName.width())/2 - 10) # hLayout1.addSpacing(spacing1) hLayout1.addWidget(lineEditName) layoutY.addLayout(hLayout1) hLayout2 = QHBoxLayout() # hLayout2.addSpacing(spacing1) hLayout2.addWidget(lineEditPassword) layoutY.addLayout(hLayout2) hLayout3 = QHBoxLayout() hLayout3.addSpacing(spacing1) hLayout3.addWidget(checkBox) layoutY.addLayout(hLayout3) # layoutY.addSpacing(5) hLayout4 = QHBoxLayout() hLayout4.addSpacing(spacing1) hLayout4.addWidget(pushButtonDomainUser) hLayout4.addSpacing(spacing1) layoutY.addLayout(hLayout4) layoutY.addWidget(buttonBox) layoutY.addSpacing(20) self.dialogRegistration.setLayout(layoutY) self.moveToCenter(self.dialogRegistration, 0, 100) if self.dialogRegistration.exec() == QDialog.Accepted:
-
So you hide all your application windows and only show the dialog ? Correct ?
And there's no entry on the desktop bar related to your dialog ? -
-
Please provide a minimal runnable script that shows your issue.
-
I create QAplication, create object class with Qwidget (this class QDialog), show QDialog (QWidget is hiden)
-
As I already requested: please provide a minimal runnable script that shows that behaviour.
-
if __name__ == '__main__': # print(sys.argv) minicondaPath = "../../miniconda3" if len(sys.argv) >= 2: minicondaPath = sys.argv[1] default_qgis_path = '/usr' conda_prefix = os.environ.get('CONDA_PREFIX') if conda_prefix is not None: default_qgis_path = conda_prefix import platform if platform.system() == 'Windows': default_qgis_path = os.path.join(default_qgis_path, 'Library') app = QgsApplication([], True) app.setPrefixPath(os.environ.get('QGISPATH', default_qgis_path), True) app.initQgis() mainWindow = MainWindow(app) mainWindow.configOS.setMinicondaPath(minicondaPath) boolEnter = mainWindow.dialogRegistrationFunction() if boolEnter == None: boolEnter = True if boolEnter: app.exec()
-
You know that this is neither a minimal nor runnable script that shows your issue ?
There's no definition of MainWindow.
It requires an installation of QGIS
You are using a conda environment somewhere but it's not clear whether your script runs within it or just makes use of it at some point. -
from PyQt5 import QtCore, QtGui, QtWidgets, uic from PyQt5 import Qt from PyQt5.QtCore import QObject, QAbstractTableModel, QSortFilterProxyModel, QAbstractItemModel, QFile, QIODevice, QDir, QVariant, pyqtSignal, QPoint, QDateTime from PyQt5.QtCore import QSettings, QUrl, QCoreApplication, QThread, QRect, QTimer, QDateTime, QEvent, QSize from PyQt5.QtWidgets import QMainWindow, QDialog, QFileDialog, QLineEdit, QTextEdit, QToolBar, QAction, QDialogButtonBox, QFormLayout, QMessageBox, QDockWidget, QApplication from PyQt5.QtWidgets import QVBoxLayout, QHBoxLayout, QGridLayout, QWidget, QLabel, QPushButton, QGroupBox, QSpacerItem, QDesktopWidget, QStyle, QShortcut, QItemDelegate, QStyledItemDelegate from PyQt5.QtWidgets import QSlider, QCheckBox from PyQt5.QtGui import QColor, QMouseEvent, QIcon, QPixmap, QFont, QPalette, QImage, QBrush, QCursor, QMouseEvent import sys class MainClass(QWidget): def __init__(self): super(MainClass, self).__init__() def dialogRegistrationFunction(self): self.dialogRegistration = QDialog(self) self.dialogRegistration.setWindowModality(QtCore.Qt.ApplicationModal) self.dialogRegistration.setWindowTitle("Авторизация") self.dialogRegistration.setWindowFlag(QtCore.Qt.FramelessWindowHint) self.dialogRegistration.setFixedWidth(420) self.dialogRegistration.setMinimumHeight(520) styleSheet = self.dialogRegistration.styleSheet() styleSheet += "; background-color: rgb(16,40,84); border-image: url(./images/Fon2.png) stretch;" self.dialogRegistration.setStyleSheet(styleSheet) styleSheet.replace("; background-color: rgb(16,40,84); border-image: url(./images/Fon2.png) stretch;", "") lineEditName = QLineEdit() lineEditName.setPlaceholderText("Имя") lineEditName.setFixedWidth(250) lineEditName.setStyleSheet( "background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch; font: 15;") lineEditPassword = QLineEdit() lineEditPassword.setPlaceholderText("Пароль") lineEditPassword.setFixedWidth(lineEditName.width()) lineEditPassword.setEchoMode(QLineEdit.Password) lineEditPassword.setStyleSheet( "background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch; font: 15;") checkBox = QCheckBox() checkBox.setText("Показать пароль") checkBox.setStyleSheet( "background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch; ") def onCheckBoxStateChanged(state): if state == 0: lineEditPassword.setEchoMode(QLineEdit.Password) else: lineEditPassword.setEchoMode(QLineEdit.Normal) checkBox.stateChanged.connect(onCheckBoxStateChanged) self.flagEnterDomainUser = False def onPushButtonDomainUserClicked(): self.dialogRegistration.hide() self.flagEnterDomainUser = self.enterDomainUser() pushButtonDomainUser = QPushButton() pushButtonDomainUser.setStyleSheet( "background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch;") pushButtonDomainUser.setText("Войти как доменный пользователь") fontButtonDomainUser = QFont() fontButtonDomainUser.setPixelSize(12) pushButtonDomainUser.setFont(fontButtonDomainUser) pushButtonDomainUser.hide() buttonBox = QDialogButtonBox() buttonBox.setCenterButtons(True) # buttonBox.setStyleSheet(styleSheet) buttonBox.setStyleSheet("background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch;") buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonBox.button(QDialogButtonBox.Ok).setText("Войти") # buttonBox.button(QDialogButtonBox.Ok).setText(" ") buttonBox.button(QDialogButtonBox.Cancel).setText("Отмена") buttonBox.accepted.connect(self.dialogRegistration.accept) buttonBox.rejected.connect(self.dialogRegistration.reject) buttonBox.button(QDialogButtonBox.Ok).setStyleSheet( ";background-color: rgb(0,155,221); border-image: url(./images/________.png) stretch; ") buttonBox.button(QDialogButtonBox.Cancel).setStyleSheet( ";background-color: rgb(16,40,84); border-image: url(./images/________.png) stretch; ") fontButton = QFont() fontButton.setPixelSize(17) widthButton = 110 buttonBox.button(QDialogButtonBox.Ok).setFont(fontButton) buttonBox.button(QDialogButtonBox.Cancel).setFont(fontButton) buttonBox.button(QDialogButtonBox.Ok).setFixedWidth(widthButton) buttonBox.button(QDialogButtonBox.Cancel).setFixedWidth(widthButton) buttonBox.button(QDialogButtonBox.Ok).setIcon(QIcon("")) buttonBox.button(QDialogButtonBox.Cancel).setIcon(QIcon("")) fontLineEdit = QFont() fontLineEdit.setPixelSize(17) lineEditName.setFont(fontLineEdit) lineEditPassword.setFont(fontLineEdit) # layout = QFormLayout() layoutY = QVBoxLayout() layoutY.addSpacing(380) hLayout1 = QHBoxLayout() spacing1 = int((self.dialogRegistration.width() - lineEditName.width()) / 2 - 10) # hLayout1.addSpacing(spacing1) hLayout1.addWidget(lineEditName) layoutY.addLayout(hLayout1) hLayout2 = QHBoxLayout() # hLayout2.addSpacing(spacing1) hLayout2.addWidget(lineEditPassword) layoutY.addLayout(hLayout2) hLayout3 = QHBoxLayout() hLayout3.addSpacing(spacing1) hLayout3.addWidget(checkBox) layoutY.addLayout(hLayout3) # layoutY.addSpacing(5) hLayout4 = QHBoxLayout() hLayout4.addSpacing(spacing1) hLayout4.addWidget(pushButtonDomainUser) hLayout4.addSpacing(spacing1) layoutY.addLayout(hLayout4) layoutY.addWidget(buttonBox) layoutY.addSpacing(20) self.dialogRegistration.setLayout(layoutY) if self.dialogRegistration.exec() == QDialog.Accepted: return True else: return False if __name__ == '__main__': app = QApplication(sys.argv) mainClass = MainClass() mainClass.dialogRegistrationFunction() app.exec() app.quit()
-
@Mikeeeeee You think this is "minimal" script to reproduce the issue?
-
@jsulm said in QDialog in Windows haven't icon in taskbar:
You think this is "minimal" script to reproduce the issue?
Yes
-
Need do this
self.dialogRegistration = QDialog()
-
@Mikeeeeee
You are asking other people to spend their time looking through your code and figuring what might be wrong. "Minimal" essentially means "the minimum number of lines to reproduce the problem; all extraneous lines have been removed". Yes, that means to get an answer you are expected to spend some time going through what you are working on and reduce it to the minimum necessary to reproduce your problem. Yes, that takes a bit of effort. Just like you are asking other people to spend in order to help you....Purely as an example, in your code why do I have to wade through lines & lines of
lineEditName
andlineEditPassword
code, with fixed widths, stylesheets and everything else, to reproduce your question about a dialog not having an icon in the taskbar? Did you try removing them before you posted to see whether they affect the issue?Good luck finding someone who will care to take the time to answer, given how much time you have taken to produce the example.