qdialog

Opening a QDialog and saving last state

拥有回忆 提交于 2019-12-31 02:44:08
问题 I am trying to open a QDialog from a QMainWindow , and after closing the `QDialog, if I need to open it again, it has to open and show the same information that had when I close it. Here is the code of the QMainWindow : class A (QMainWindow): def __init__(self): QMainWindow.__init__(self) #I create a QPushButton to open the QDialog self.axes1 = self.figure_canvas.figure.add_axes ([0.8, 0.01, 0.19, 0.05]) self.button = QPushButton(self.axes1,"Open Dialog") self.button.on_clicked(self

QDialog exec() and getting result value

落爺英雄遲暮 提交于 2019-12-28 03:04:13
问题 I have subclassed QDialog to implement functionality similar to QMessageBox ( I needed this to allow for customization). It has a text message and OK, Cancel buttons. I am showing the dialog using exec() to make it blocking. Now, how do I return values of true/false when the user clicks on OK/Cancel? I tried connecting the buttons to setResult() and then, return the result value when clicked, but Clicking the buttons does not close the dialog box the return value is incorrect. Following is

Qt - draw inside QScrollArea in a QDialog

假如想象 提交于 2019-12-25 04:24:20
问题 In Qt 5, I have a QDialog window on which I have drawn a circle as follows: void MyDialog::paintEvent(QPaintEvent *pe) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing,true); QPen pen(Qt::blue,2); painter.setPen(pen); QRect r=QRect(0,0,100,100); painter.drawEllipse(r); } If I draw a larger circle, for example by using QRect(0,0,500,500); , the circle being greater than the dialog window is clipped. So I dragged a QScrollArea onto the the dialog window and decide to draw

how to set QDialog width and height and allow automatic window placement

↘锁芯ラ 提交于 2019-12-23 11:55:27
问题 Is there a way to just initialize a QDialog's width and height and not change the x and y coordinates without using a ui file? I just have a simple QDialog and want to set only the width and height, and have the x and y automatically set to the center of the parent, but when I try setGeometry, the inherited geometry's x and y are 0. How does the x and y get set when the dialog is created using a ui file? class MyDialog : public QDialog { MyDialog::MyDialog(QWidget *parent) : QDialog(parent) {

QDialog remove title bar

家住魔仙堡 提交于 2019-12-23 10:16:56
问题 The net is flooded with similar questions, but for all I have seen nothing suits to solve the problem at hand. In my QT-C++ app, I have a mainwindow form with some functions, there is a QPushButton, Pressing which a QDialog opens. Now, all functionalities in forms work fine, but I want the final application to be without any top title bar. i.e. No Close / Minimize / Maximize Button. In my main.cpp I have done -- int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w

How to show a window in Qt and deleting it as soon as it's closed?

被刻印的时光 ゝ 提交于 2019-12-23 07:55:27
问题 As a very simple example, I want to show a dialog in Qt when I press a button. The usual pattern for this (in the application I'm currently working on) seems to be as follows: class MainWindow { ... private slots: buttonClicked(); ... private: ChildWindow * childWindow; } MainWindow::MainWindow(QWidget * parent) : QWidget(parent) { ... childWindow = new ChildWindow(this); ... } MainWindow::buttonClicked() { childWindow.show(); } Coming from .NET and Windows Forms (and because I don't need

Simple way to embed a QDialog into a QWidget

﹥>﹥吖頭↗ 提交于 2019-12-22 09:34:40
问题 I have been searching for a simple way to embed QDialog instances in a QWidget , but all I found used OpenGL or some rather complex stuff to achieve that. Actually, all the examples I found tried to achieve many more things than simply embed the QDialog . So, I am wondering: is there a simple and clean way to embed a QDialog in a QWidget ? P.S.: I tagged pyqt since it's what I'm using, but I will of course accept c++ answers :) Here is a screen capture of the piece of software I have to port

QDialog - How to remove the minimize button

主宰稳场 提交于 2019-12-22 09:20:06
问题 Qt 4.8 based, application - Issue with QDialog, minimize button Windows and Gnome (linux) The modal dialog appears with the close button on the right top, and the minimize button is nonexistent . The minimize option are grayed out in every dialog. This makes sense, since the QDialog is modal - if you minimize it, the whole application will be blocked. But here comes the issue: in KDE (linux) the minimize-maximize button appears. It seems that this is a platform dependent feature - I am not

Non-pixelized rounded corner for top-level window

二次信任 提交于 2019-12-22 08:41:01
问题 I want to set rounded corners on a QDialog. Since it is a top-level window, border-radius doesn't work, so I've to do this : QRegion EnterPinDialog::roundedRect(const QRect& rect, int r) { QRegion region; // middle and borders region += rect.adjusted(r, 0, -r, 0); region += rect.adjusted(0, r, 0, -r); // top left QRect corner(rect.topLeft(), QSize(r*2, r*2)); region += QRegion(corner, QRegion::Ellipse); // top right corner.moveTopRight(rect.topRight()); region += QRegion(corner, QRegion:

Load QDialog directly from UI-File?

↘锁芯ラ 提交于 2019-12-22 08:06:49
问题 I work with QT Designer and create my GUIs with it. To launch the main program, I use this code: import sys from PyQt4 import uic, QtGui, QtCore from PyQt4.QtGui import * from PyQt4.QtCore import * try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context,