Questions tagged [qpushbutton]

QPushButton is a Qt library class that represents ordinary push buttons, and gives the API to manipulate them.

QPushButton offers a set of functions to manipulate the button's appearance and behavior.

A minimalistic QPushButton example will look like this:

#include <QtGui>
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a( argc, argv );
    QPushButton * myButton = new QPushButton("Hello, World!");
    myButton->show();
    return a.exec();
}

One of QPushButton's most notable properties is Checkable, which can be accessed via setCheckable( bool ) function. If this option is set to true, the QPushButton becomes a toggle button which can be toggles on and off, and will stay in the corresponding state until toggled again.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

631 questions
4
votes
1 answer

Get function linked to the "QPushButton.clicked.connect" signal

I'm trying to get statistics on how many time a button was clicked in PySide. Data is stored in a dictionnary, and I'd like the key to be the clicked-function name: Example : {"myAwesomeFunc" : 15, "anotherFunc" : 4} I start with converting my…
Ben
  • 244
  • 2
  • 9
4
votes
1 answer

QTableView row remove

I created a table view like this: I have a create button to create new rows and as you can see I defined a button for each row to delete that row by this code: int i = 0; QPushButton *viewButton; QStandardItemModel *model; void…
HMD
  • 2,202
  • 6
  • 24
  • 37
4
votes
2 answers

Change styling of flat QPushButton hover state (without using style sheets)

Flat QPushButtons have no indication of mouse hovering. Is there a way to set the styling for the flat button hover state so that it matches the style of the normal button hover state (or something similar)? I don't want to use style sheets if it…
101
  • 8,514
  • 6
  • 43
  • 69
4
votes
4 answers

pyQt QPushButton colour

Writing in Python 2.7 using pyQt 4.8.5: What is the default background colour of a pyQt QPushButton widget? I am able to set the colour green but not return it to the default colour. A snap shot of what I mean: The function responsbile for…
Harry Lime
  • 2,167
  • 8
  • 31
  • 53
4
votes
2 answers

How to do - QToolButton inside the QlineEdit : Qt5

I want to add QToolButton inside the QLineEdit. I want to clear the text of QLineEdit control on that button click. For example how in google image: I have looked : This StackOverflow article But still not solved my issue. Thanks in Advance.
AB Bolim
  • 1,997
  • 2
  • 23
  • 47
4
votes
3 answers

Qt Background Image for a QPushButton

I need to put an image from the internal resources as a background image of a QPushButton. I need also to adapt the size of the image to the size of the button. I have found here some way to do that, but nothing seems to work. In the last reply it…
Rudy Barbieri
  • 389
  • 1
  • 4
  • 16
4
votes
1 answer

How to set QPushButton stylesheet affecting buttons size?

When I QApplication::setStyleSheet() with the following stylesheet QPushButton { border-radius: 2px; padding: 0.2em 0.2em 0.3em 0.2em; border: 1px solid rgb(100, 100, 100); background: qlineargradient(x1:0, y1:0, x2:0, y2:1, …
Uga Buga
  • 1,724
  • 3
  • 19
  • 38
4
votes
1 answer

Qt4, QMenu addAction, connect function with arguments

I would create a button with 3 choices that changes its text when you make a choice. This solution works for me: def swTrigger(self): self.setTrigger(self.ui.triggerButton,'Software') def hwTrigger(self): …
salvo
  • 63
  • 1
  • 8
4
votes
4 answers

PyQt: Can a QPushButton be assigned a QAction?

Using Python 3.2x and PyQT 4.8x: I initialized an action and assigned to a menu item: self.__actionOpen =…
Vector
  • 10,879
  • 12
  • 61
  • 101
4
votes
2 answers

How can I create a 3 state custom push button?

I need to create a custom push button which will have 3 different background images corresponding to the following states: normal mouse over mouse down I would like to have a QHBoxLayout with 3 parts for left side, right side and middle side…
Phil
  • 13,875
  • 21
  • 81
  • 126
3
votes
1 answer

Error lambda missing 1 required positional argument when using with QPushButton

This is entire my code: import sys from PySide2.QtCore import Qt from PySide2.QtWidgets import ( QApplication, QHBoxLayout, QLabel, QMainWindow, QPushButton, QVBoxLayout, QWidget, ) class MainWindow(QMainWindow): …
3
votes
1 answer

How to align a QPushButton inside window?

I want to align a QPushButton to the bottom right corner, but without a fixed size, because if I use a fixed size and resize the window, it doen't look good anymore. Here's my code: self.copy_btn = QtWidgets.QPushButton(self) …
user11452535
3
votes
1 answer

connect a function when menu title is clicked

I am trying to find open ports and add them to my menu. Right now, what I succeed having an action to my menu (like, "find ports"), and only if it's clicked - it will connect to my function that gets all free ports. Unfortunately, that's not what I…
Alon123
  • 164
  • 3
  • 15
3
votes
1 answer

Button resizing automatically

I am using PyQt5 and I am trying to prevent push button from resizing automatically. So I used this code to achieve this. My goal was if I create a button with fixed size, it won't resize on its own. So I wrote the following code: rect =…
Man_From_India
  • 207
  • 1
  • 4
  • 10
3
votes
2 answers

function call through signal changes default keyed arguments to 'False'. Why?

When calling a function via a signal connection as in mybutton.clicked.connect(myfunction) the function is called with all its arguments set to False. Even though default arguments have been set. Is this the expected behavior? The code below shows…
pcsso
  • 121
  • 2
  • 9