signals-slots

Connecting an overloaded PyQT signal using new-style syntax

北慕城南 提交于 2020-01-09 10:29:17
问题 I am designing a custom widget which is basically a QGroupBox holding a configurable number of QCheckBox buttons, where each one of them should control a particular bit in a bitmask represented by a QBitArray. In order to do that, I added the QCheckBox instances to a QButtonGroup, with each button given an integer ID: def populate(self, num_bits, parent = None): """ Adds check boxes to the GroupBox according to the bitmask size """ self.bitArray.resize(num_bits) layout = QHBoxLayout() for i

Qt Creator - how to see the code of the designer?

风格不统一 提交于 2020-01-06 03:59:38
问题 I'm using Qt Creator . I'm using the signals and slots editor, and I want to see the code it generates. How can I see the code? Thanks! 回答1: Let's say you have in Qt Creator a form file called widget.ui . Once you've compiled your project, you'll find in your project folder a filed called ui_widget.h . If you open it, you'll see the code generated by the uic tool. 回答2: when you use qt creater, this one is going to create a file with the name of your project, in my case it is called "build

Is it possible to have a QWidget as a child to a QObject?

无人久伴 提交于 2020-01-04 04:25:13
问题 My main application object is a QObject , that juggles a QSystemTrayIcon , a QDialog , a QWindow and a few other components. The app mostly sits in the tray, with some options dialogs etc etc. Now, I'd like to use QMetaObject::connectSlotsByName() to connect signals from these objects to slots in the main object. It's 10-15 of them, so writing them by hand doesn't seem efficient, right, professional, modern, etc etc. However, I can't use my QObject as parent to the QWidget based objects, nor

Why is Qt looking for my slot in the base class instead of derived one?

陌路散爱 提交于 2020-01-03 06:45:12
问题 I have my class X which inherits from Qt's class Base . I declared and defined void mySlot() slot in my class X and I'm connecting some signal to this slot in X's constructor. However, when running my program I get an error message saying there's no such slot as void mySlot() in the class Base . Why is the code generated by Meta Object Compiler (moc) looking for my slot in the base class and not in my (derived) class? 回答1: Did you add the Q_OBJECT macro on the derived class? 回答2: From #qt irc

Qt signals and slots for multiple objects

点点圈 提交于 2020-01-03 04:23:16
问题 I'm having little problem here. I'm having troubles with signals & slots. I'll try to explain with pseudocode. So, here it goes. I have main thread (mainwindow.cpp) where I'm creating new objects when new client connects. mainwindow.h: signals: void changeText(); ... mainwindow.cpp: connect(tcpserver, SIGNAL(changeText()), this, SIGNAL(changeText())); ... MyClass *m = new MyClass(this); connect(this, SIGNAL(changeText()), m, SLOT(changeText())); I have also tcpserver class, which creates new

Updating pointer using signals and slots

醉酒当歌 提交于 2020-01-02 13:44:05
问题 I am very new to Qt; please help me to solve the problem. I am using a thread to perform intensive operations in the background. Meanwhile I want to update the UI, so I am using SIGNALS and SLOTS. To update UI I emit a signal and update UI. Let us consider below sample code, struct sample { QString name; QString address; }; void Update(sample *); void sampleFunction() { sample a; a.name = "Sachin Tendulkar"; a.address = "India" emit Update(&a); } In the above code we are creating a local

QT: No Such Slot

家住魔仙堡 提交于 2020-01-02 06:31:07
问题 Problem is that I keep getting the 'No Such Slot' runtime error in Qt Creator every time I launch a 'settings' window from my main window. I've found Qt to be quite counter-intuitive so far and this slots 'n signals concept seems a bit of a stretch from simply passing vars or function calls. Basically, I have menu with a settings option, that when clicked, opens a settings window which needs to grab a double from the user and update a var in the main window. SettingsWindow.h class

Slot seemingly not recognized in Qt app [duplicate]

白昼怎懂夜的黑 提交于 2019-12-31 05:29:09
问题 This question already has answers here : C++ Qt signal and slot not firing (3 answers) Closed 5 years ago . I have been working on learning C++ and Qt4 recently, but I have hit a stumbling block. I have the following class and implementation: class Window : public QWidget { public: Window(); public slots: void run(); private: //... }; and Window::Window() { //... connect(runBtn,SIGNAL(clicked()),this,SLOT(run())); //... } Window::run() { //... } However, when I attempt to build and run it,

Pycharm debugger works on Ubuntu but not on Windows for identical code

我的未来我决定 提交于 2019-12-30 11:00:11
问题 Update: Issue being tracked here Edit: I may not be the only one with this issue. I missed this which was also posted today and it looks related: PyCharm debugger doesn't work Below is a minimal example that runs fine on both Windows 7 and Ubuntu 14.04 when using Pycharm Professional PyCharm 2016.1 Build #PY-145.260, built on March 22, 2016 JRE: 1.8.0_60-b27 x86 JVM: Java HotSpot(TM) Server VM by Oracle Corporation Now the uber-weird part: On Ubuntu's Pycharm debugger I get no issue. However,

QLabel click event using Qt?

試著忘記壹切 提交于 2019-12-30 08:52:09
问题 I'm new in Qt and have a question. I have QLabel and QLineEdit objects, and when QLabel text is clicked on, I want to set this text in QLineEdit . Also I have read that QLabel has not clicked signal. Can you explain how can I do this and write code for me ?! 回答1: Either style another type of QWidget such as a specific QPushButton to look like a QLabel and use its clicked() signal or inherit QLabel yourself and emit your own clicked() signal. See this example: https://wiki.qt.io/Clickable