signals-slots

Why is PyQt executing my actions three times?

守給你的承諾、 提交于 2019-12-12 08:11:32
问题 I'm still kind of new to PyQt but I really have no idea why this is happening. I have a Mainwindow that I create like this: class MainWindow(QtGui.QMainWindow): #initialize def __init__(self): #Call parent constructor super(MainWindow, self).__init__() #Load the interface self.ui = uic.loadUi(r"Form Files/rsleditor.ui") #Show the ui self.ui.show() and when I wanted to override the close event with: def closeEvent(self, event): quit_msg = "Are you sure you want to exit the program?" reply =

How to use templates with QT signals and slots?

こ雲淡風輕ζ 提交于 2019-12-12 07:57:42
问题 I want to use signals and slots in my program, but unfortunately they should be used for transmitting several different data types (e.g. QString, double, etc.) and I don't want to write twenty different slots just because I need one for each data type. But when I want to declare a slot like template <typename t> void Slot1(t data); QT tells me that it is not possible to use templates in signals and slots. Is there a workaround? Or can my approach simply improved? 回答1: Accurate answer: It is

Can't emit signal in QML custom Item

耗尽温柔 提交于 2019-12-12 06:19:15
问题 I created my own Item with signal clicked , that contatins MouseArea. I want to emit signal clicked , when MouseArea is clicked. But nothing works. Here is my .qml code: import QtQuick 2.4 Item { id: baseButton property alias text: txt.text width: txt.width height: txt.height signal clicked onClicked : console.log("Clicked!") Text { id: txt color: "white" font.pointSize: 8 anchors.centerIn: parent } MouseArea { id: mousearea anchors.fill: parent hoverEnabled: true onEntered: { txt.color =

Slot gets called twice despite pyqtSlot decorator

扶醉桌前 提交于 2019-12-12 04:32:51
问题 This is a class which form i made in qt5 designer. The slot is called twice when I click the button. class CustomerList(QWidget, Ui_CustomerList): def __init__(self, parent=None): QWidget.__init__(self, parent) self.setupUi(self) self.buttX.clicked.connect(self.on_buttX_clicked) @pyqtSlot() def on_buttX_clicked(self): print("on_buttX_clicked") if __name__ == '__main__': app = QApplication(sys.argv) w = CustomerList() w.show() sys.exit(app.exec_()) What am I missig here? 回答1: Your button is

How do I connect a signal to a slot in a static method? [closed]

痞子三分冷 提交于 2019-12-12 03:53:39
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I'm trying to show a popup window from within a static method: void MainThread::popup(void){ static klassePopup* roiPopup; roiPopup = new SavingROI(); roiPopup->show();} This code works fine, I get my window with

Qt Designer UI (python) to JSON

家住魔仙堡 提交于 2019-12-12 03:47:15
问题 I recently started using qt to build a python GUI. I have two problems I can't quite find the solutions to. the code below is a sample of what I need to build. 1: Check which radio button from a list of radio buttons in a vertical layout has been clicked. In the GUI it only selects one radio button out of all others available in the layout. How do I perceive which has been clicked? 2:I would like to add the clicked value to a JSON object but I believe that is a simple if statement of if this

QT/C++ yet another issue about accessing UI files

徘徊边缘 提交于 2019-12-12 02:53:38
问题 Although I have read the answers to this question QT/C++ - Accessing MainWindow UI from a different class and searched the whole www for quite some time - I don't get it working. I was given the task to recreate an applications UI using QT Designer. Unfortunately there was already some UI spread all over several classes (the team then came across the idea, that using QT but not using the Designer however "handcoding" the UI seems to make little sense) So now my job is to untangle the open

How to add a slot to a QWidget?

筅森魡賤 提交于 2019-12-12 00:45:08
问题 I have a QMainWindow, which has a QAction whose signal triggered() is connected to a slot about2() . ... connect(mAboutAction2, SIGNAL(triggered()), this, SLOT(about2())); ... void occQt::about2() //UI { QWidget* pWidget = new QWidget; QPushButton* okbtn = new QPushButton(tr("ok")); QPushButton* cancelbtn = new QPushButton(tr("cancel")); btnlayout->addWidget(okbtn); btnlayout->addWidget(cancelbtn); dlglayout->setMargin(50); dlglayout->addLayout(gridlayout); dlglayout->addStretch(40);

qt signals cause segmentation fault on connect

好久不见. 提交于 2019-12-12 00:31:14
问题 I made a widget that behaves as a window and when a button is pressed it simply emits a signal: signals: void SaveTask( void ); in my mainwindow.cpp I define (in the constructor): connect( taskWindow, SIGNAL(SaveTask()), task_view, SLOT(UpdateFromTasks()) ); taskWindow = pointer to window where this signal emits. task_view = pointer to treewidget in mainwindow with a slot. It is designed so that when you save a task it is displayed in the treeview. unfortunately when I try to run the program

QAction won't connect to my slot

梦想与她 提交于 2019-12-11 17:18:35
问题 I'm trying to make an IHM with Qt, and I started by making a basic menu (File,Edit...). So far, I have my menu containing "File", which then display "New Project, Open Project, Exit". Look great, but my problem is I can't seem to trigger these Action (clicking them or by key shortcut). Here is my slot: void KoriganEngine::launchNewProjectWidget(){ //External QWidget m_nwProj = new NewProjectWidget(NULL,Qt::MSWindowsFixedSizeDialogHint); m_nwProj->show(); } If I use this slot with a pushbutton