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
2
votes
1 answer

How to enable/disable button for a given interval

class MyWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("My Window") self.setGeometry(400, 400, 400, 200) btn1 = QPushButton("button1", self) btn1.move(20, 20) …
2
votes
1 answer

PyQt5: Can QAction function be triggered via QPushButton

I have created a right-click menu function where all the right-click functions are linked to a QAction Eg: self.contextMenu =…
Sean Ang
  • 37
  • 5
2
votes
1 answer

QLineEdit emits returnPressed when getting focus triggered by other returnPressed singal

I've 2 QlineEdit and a QPushbutton QLineEdit *field1 = new QlineEdit(); QLineEdit *field2 = new QLineEdit(); QPushButton *button = new QPushButton(); What I want: If the user presses return in field1 the focus shall be changed to field2. If the…
Maro
  • 43
  • 6
2
votes
1 answer

How to detect a button click in a QTableView rows cell

I was able to insert PushButton in a QtableView cell. import sys from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QTableView, QPushButton, QAbstractItemView from PyQt5.QtGui import QStandardItemModel, QStandardItem app =…
Ansh David
  • 654
  • 1
  • 10
  • 26
2
votes
1 answer

reference to type 'const QVariant' could not bind to an rvalue of type 'void'

I am trying to save the following modification : to enable the pushButton_4. void Vessels::SaveSettings() { QSettings setting("My_vessels","My_selected_vessels"); setting.beginGroup("Vessels"); …
2
votes
1 answer

How can I know wether a pushbutton is toggled or not?

Like seen on the picture, I have 96 pushbuttons initially green. Once clicked on a button ( toggled(bool) ) it becomes red. What I want to do is to disable all red buttons once I click on the OK button. How can I do that ? If the OK button closes…
2
votes
1 answer

Show push button with "pressed" state in QTableView

I have created a delegate to show push buttons in a QTableView. It looks like this (last two columns): Here's the code for the delegate's paint method: void PushButtonDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, …
geschema
  • 2,464
  • 4
  • 30
  • 41
2
votes
1 answer

Python PyQt5 - Is it possible to add a Button to press inside QTreeView?

I want to add a QPushButton to the tree view that ends with .pdf and when I click it I want to return the path for that Index it's assigned at. This might not even be possible with the Native QTreeView but if anyone could guide me in the right…
JareBear
  • 467
  • 9
  • 27
2
votes
1 answer

Pyqt5 draggable QPushButton

I have this sample code on how to drag and move a QPushButton. The only issue of that code is, when you drag the button and release it, the button status is stay as checked. Can someone help me to change the code so that, after drag the button and…
Dr. Zezo
  • 395
  • 2
  • 17
2
votes
2 answers

How to make invisible button on widget with background image?

I want to make a simple application with invisible button. I set background image for my widget by UI property styleSheet and Resources - border-image:url(:/image.jpg). I always get something like this and then I try to add button on it I was…
EmmaStone
  • 23
  • 8
2
votes
1 answer

Changing QLabel on a push of a button each time its pressed it's overwrited

I want to print out the average of a set of 3 numbers the user inputs. However ever time I push the button the text overlaps eachother def Comp Average = QtGui.QLabel("The Students Average is " + str(self.average), self) …
Ayman Almuti
  • 51
  • 1
  • 8
2
votes
1 answer

How to remove all widgets within a QGroupBox in PyQt5?

In my program there is a QGroupBox displayed that has many QPushButton's within it. During the execution of the program, the user can click a button outside of the QGroupBox and all of the buttons within it will be removed or hidden. Problem is that…
Matthew64
  • 35
  • 1
  • 5
2
votes
1 answer

application wide logging when any QPushButton being pressed

Suppose I have an application that is made using Qt. There I have a bunch of QPushBUttons here and there. I want to be able to log the moment when any of QPushButton being pressed. (application wide). Assuming the existing code should be intact,…
libxelar.so
  • 473
  • 4
  • 16
2
votes
1 answer

How to add widget to center of the gridlayout using with pyqt4

here in my sample program i want to add widget to Center of the gridlayout.I used alignments methods but its not working.Can any one please help me how to adjust the my widget in center of the grid layout. Thank you in advance. Given below is my…
raghava
  • 119
  • 2
  • 11
2
votes
1 answer

QTabWidget strange behavior

I have two tabs where placed QTableWidget with cell widget. See image. QTabWidget *tab = new QTabWidget(this); for (int i = 0; i < 2; ++i) { QTableWidget *t = new QTableWidget(1, 1); QPushButton *btn = new QPushButton("Click on me!"); …
Nick Brian
  • 53
  • 5