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
8
votes
3 answers

How to change QPushButton icon using stylesheets?

Is it possible to set and change the icon on a QPushButton using stylesheets? I need this for a Windows-based white-label Qt4.5 application that customers stylize using stylesheets.
Robin
  • 695
  • 2
  • 8
  • 23
7
votes
1 answer

How to set QPushButton size in QGridLayout in Qt

I am currently learning qt. And I am trying to build a small GUI program with 81 QPushButton on it. I want to set those buttons to 9 rows and 9 cols. The best way I can think to implement this layout is using QGridLayout. This is how that looks…
Theodore Tang
  • 831
  • 2
  • 21
  • 42
7
votes
1 answer

How to style QPushButton's checked state to remove grey dots?

I am using Qt 5.3.0. When I apply some background-color on the QPushButton's checked state, the button will be filled with grey dots (over the background color I wanted) when it is checked. Here is a tiny test program (with qtcreator but it can also…
K--
  • 659
  • 1
  • 7
  • 18
7
votes
2 answers

Stacking QPushButtons on the other side of a QMenuBar

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…
iTayb
  • 12,373
  • 24
  • 81
  • 135
7
votes
2 answers

Shrink a QPushButton width to the minimum

This seems like such a simple thing, but I can't seem to figure it out. How do I make the button the minimum width. It keeps expanding to the width of the layout I put it in. In the following example, the QPushButton width ends up the same as the…
noisygecko
  • 1,771
  • 3
  • 15
  • 13
6
votes
2 answers

PyQt: Add qpushbutton dynamically

I am trying to figure out how to create QPushButton by pressing another QPushbutton so that I can ultimately create buttons dynamically. It seems like the initial method for creating buttons doesn't work in a function. import sys from PyQt5 import…
riyadude
  • 337
  • 6
  • 18
6
votes
1 answer

Check the state of QPushButton in PyQt4?

I want to write a if with a condition as the state of QPushButton. I would like to execute if if the button is enabled. So, how can i check the state of the Button. Code: self.pushButton =…
learncode
  • 1,105
  • 4
  • 18
  • 36
6
votes
3 answers

Two colours text in QPushButton

I need a QPushButton with two colors in the text. I found a solution with a html code in QTextDocument and it's working. But I need center align and the html code isn't working. QTextDocument Text; Text.setHtml("
ChavesJM
  • 183
  • 2
  • 12
6
votes
3 answers

Make QPushButton invisible yet still work?

In my project, I have some pushbuttons that change between visible and invisible using this: ui->button->setVisible(true); //or ui->button->setVisible(false); However, it seems that when they are invisible, they also do not work? How can I get…
mrg95
  • 2,371
  • 11
  • 46
  • 89
6
votes
3 answers

Qt - how to save my QTableView as a Excel File?

Can anyone plz help me, how to save my QtableView as a Excel File. I have a QTableView and a QPushButton (Save Button). If i enter the values in my QtableView and if i click the Save Buttton the QTableView items should be saved as Excel File. Plz…
New Moon
  • 787
  • 6
  • 21
  • 35
6
votes
4 answers

QPushButton visual issue

I have two custom-styled QPushButton buttons. Here is the stylesheet for the Ok button: QPushButton { background-color:#9dce2c; border-radius:7px; border:1px solid #83c41a; color:#ffffff; font-size:15px; font-weight:bold; …
SingerOfTheFall
  • 29,228
  • 8
  • 68
  • 105
5
votes
1 answer

Python: How to enable button if the QlineEdit is Filled

Can someone tell me what approach or what logic so the QPushbutton will be enable if all the fields are not empty. I'm making a simple form that you can only push the button if the fields are not empty. class Ui_MainWindow(object): def…
5
votes
2 answers

set focus on button in app with group boxes

Let's say I have an application with a number of QGroupBoxes like so: import sys from PyQt4 import QtGui, QtCore class Main(QtGui.QWidget): # pylint: disable=too-many-statements def __init__(self, main): super(Main,…
Bob Sacamano
  • 699
  • 15
  • 39
5
votes
1 answer

Qt QToolBar get button added by addAction

In Qt when we use the function addAction of a QToolBar: _LastBar->addAction(QtExtensions::Action(name, icon, func)); How could we retrieve the QToolButton generated for that action? Or, if this is not possible, how to find the last button/widget of…
Sturm
  • 3,968
  • 10
  • 48
  • 78
5
votes
1 answer

Get the list of all QPushButton in Qt

I would like to get the list of all QPushButton in my MainWindow. Actually, I have a QRadioButton, and when I uncheck it, I would like to disable all the QPushButton of my window. How can I do that ?
iAmoric
  • 1,787
  • 3
  • 31
  • 64
1
2
3
41 42