qpushbutton

PyQt5 Qtablewidget and connecting to buttons

邮差的信 提交于 2019-12-08 12:13:03
问题 I have created a Qtablewidget as a class, and add_button to add rows, a delete_button to remove rows from table down upwards. I would like to connect functions to buttons, but it doesn't work correctly. I have used getattr method to call the function, still does not work. The table to explain more, those scriptlines are giving attributte errors. when they are called by button.clicked.connect method. add_button.clicked.connect(self._addrow) delete_button.clicked.connect(self._removeItem) The

Qt handling QPushButton Autorepeat() behavior with isAutoRepeat()

ε祈祈猫儿з 提交于 2019-12-08 11:31:34
问题 I'm new to QT and am making a widget that interfaces with a pre-existing gui. I'd like to have my widget continuously output one signal while the user has a pushbutton pressed and then continuously output another when it is released. By enabling autorepeat I can have the widget output my signal while the user is pressing the pushbutton, however, the output signal switches between pressed() and released(). E.G. <> Outputs: * pressed signal * released signal * pressed signal * released signal I

(Qt) Create signal from QButtonGroup of PushButtons?

时光毁灭记忆、已成空白 提交于 2019-12-08 08:34:53
问题 I am so confused on how this whole thing works. I have some pushbuttons that I put into a group like this: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); AddSlotsToGroup(); } void MainWindow::AddSlotsToGroup() { QButtonGroup* group = new QButtonGroup(this); group->addButton(ui->slot_0); group->addButton(ui->slot_1); //... } And I want to create a slot that gets the id of the button that was clicked in that group. (Sorry if I

Set CSS in QPushButton's subclass's constructor

一笑奈何 提交于 2019-12-08 06:44:45
问题 I'm creating my custom push button class by subclassing QPushButton . However for some reason setting that class's CSS in its constructor has no effect; I have to do it in for example paintEvent , then everything is fine. I could just have a global .qss file and set it for the entire application, but I want the class to manage its own styles. Why doesn't my approach work? The code: custompushbutton.h class CustomPushButton: public QPushButton { Q_OBJECT public: explicit CustomPushButton

Grabbing all QPushButton in a PyQt Python ui File

旧巷老猫 提交于 2019-12-08 05:25:18
问题 I created a UI File using Qt Designer with lots of QPushButtons, and then I converted it into a python file using pyuic4. I want to add all the QPushButtons to a QButtonGroup. How do I iterate or grab all my QPushButtons to add in to a QButtonGroup from my UI Python file? 回答1: In Qt Designer, put all your buttons inside a container widget. You can then use findChildren to iterate over all the child buttons. So if self.buttonBox was your container widget, then you could do something like: self

Specific QPushButton style

好久不见. 提交于 2019-12-08 02:41:42
问题 How can I customize the look of a QPushButton or QToolButton to look something like elementaryos's webpage "buttons"? All I really want is the characteristic image position and the text on it's side, maybe if i'm lucky i can also get a border like that, but i don't really need the little description below the title :) Can i do it only with StyleSheets, or do i have to subclass QPushButton/QAbstractButton/Something like that? I already searched everywhere but didn't found that level of

Stacking QPushButtons on the other side of a QMenuBar

梦想与她 提交于 2019-12-07 05:54:05
问题 I want to stack some QPushButton objects on the other side of my QMenuBar . This is how my window looks now: And this is how I want it to look like (I've photoshopped the image): I know that in the motif widget style, the help menu is aligned to the right, but I'm sticking with plastique , so it's not a problem for me. I'm using Qt4.8. Any ideas? 回答1: QMenuBar has a setCornerWidget function, that sets a widget (that may include a whole layout) as the cornet widget. 回答2: QMainWindow:

Specific QPushButton style

Deadly 提交于 2019-12-06 14:25:39
How can I customize the look of a QPushButton or QToolButton to look something like elementaryos's webpage "buttons"? All I really want is the characteristic image position and the text on it's side, maybe if i'm lucky i can also get a border like that, but i don't really need the little description below the title :) Can i do it only with StyleSheets, or do i have to subclass QPushButton/QAbstractButton/Something like that? I already searched everywhere but didn't found that level of customization without things like painting something in a fixed place, which is exactly what i don't want.

Stacking QPushButtons on the other side of a QMenuBar

▼魔方 西西 提交于 2019-12-05 10:24:18
I want to stack some QPushButton objects on the other side of my QMenuBar . This is how my window looks now: And this is how I want it to look like (I've photoshopped the image): I know that in the motif widget style, the help menu is aligned to the right, but I'm sticking with plastique , so it's not a problem for me. I'm using Qt4.8. Any ideas? QMenuBar has a setCornerWidget function, that sets a widget (that may include a whole layout) as the cornet widget. QMainWindow::setMenuWidget() can be used to set any widget as the main window's menu bar widget. Using an appropriate layout, you can

PySide : How to get the clicked QPushButton object in the QPushButton clicked slot?

…衆ロ難τιáo~ 提交于 2019-12-04 22:04:42
问题 I am new to PySide. I want to get the QPushButton obj (such as use it to get its text) in its clicked slot. button = QtGui.QPushButton("start go") button.clicked.connect(self.buttonClick) def buttonClick(self): ... # How can I get the button object? # print button.text() how to get the text : 'start go' ? Thanks! 回答1: Here is what I did to solve the problem: button = QtGui.QPushButton("start go") button.clicked.connect(lambda: self.buttonClick(button)) def buttonClick(self, button): print