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
2 answers

QT push button / stop button

I have a push button that I'd like to change to a stop button when clicked. Currently the button's text says "auto fire", it runs an endless loop and it's text changes to "stop auto fire" when clicked. My problem is breaking the endless loop by…
Duanne
  • 137
  • 1
  • 3
  • 13
2
votes
2 answers

How to iterate all QPushButton in a QGroupBox

I have a QDialog which contains a QGroupBox which in turn contains some push-buttons. I want to differentiate the background-color of the push-button which is clicked and all the remaining push-buttonx. How to achieve this?
user2408848
  • 151
  • 7
2
votes
1 answer

How to avoid text clipping for QPushButton with borderimage

I am styling a QPushButton with a border image with 28px border (for really round corners) Like so: #MyApp QPushButton { margin:0; padding: 0; border:0; border-image: url(:/graphics/button_brand_up.png) 28 28 28 28 stretch stretch; …
Mr. Developerdude
  • 9,118
  • 10
  • 57
  • 95
2
votes
2 answers

Discarding QPushButton clicked

I'm programming a simple GUI with QtGUI in Python that allows users to start a routine by clicking a button (button1) and after 10 seconds there should be the option to click another button (button2) to start some routine. I tried…
Daniel
  • 33
  • 3
2
votes
3 answers

How to show the menu in QPushButton without blocking?

I use Qt4 QPushButton with QMenu in it (set by setMenu()). I need to show this menu when some unrelated event occurs. Method QPushButton::showMenu() does this, but it blocks until user closes the menu. QMenu::show() also does this, but it shows the…
user912889
  • 41
  • 1
  • 5
2
votes
1 answer

Qt C++ : Linking multiple instances of a QPushButton subclass using Signals/Slots

I would be very grateful if you could help me solve this : I have a subclass of QPushButton called Square and what I want to do is to change the icon of one instance by clicking another instance of Square. I have a vector of vectors of pointers to…
2
votes
1 answer

QSignalMapper Usage; Multiple QPushButtons assigned to one signal

Edit: The code below has been updated to the working solution. As an attempt to introduce myself to QT, I am trying to design a chessboard out of 64 QPushButtons. I know this might not be the best way to do this, but I believe starting with the…
halexh
  • 3,021
  • 3
  • 19
  • 19
2
votes
1 answer

Setting custom pushButton as cell widget consumes to much time

I have my push button that I set in qTableWidget column 9. It contains 3 values so when it's clicked it send signal with those values to my main that triggers DoSomething() method in my main. Problem is that this line consumes to much time…
Aleksandar
  • 3,541
  • 4
  • 34
  • 57
2
votes
1 answer

Generate Qt push buttons within the code

I am building a simple C++ application with GUI. I'm using the latest Qt (5.2). So my problem - I want to build something like minesweeper field on my window and I want to ask how can I create buttons within the code of the program so I can create…
Bankin
  • 777
  • 1
  • 16
  • 31
2
votes
1 answer

sending a parameter by button press with QPushButton

I have a QDialog with one QLabel, one QLineEdit and one QPushButton "Find". After pushing the button I would like to send the text entered in QLineEdit to another function which will handle the action for find button. # shows and handles the find…
Orcl User
  • 293
  • 1
  • 5
  • 20
2
votes
3 answers

Change icon on state change using Qt stylesheet

I'm trying to support theming for my application, and I'm coming across a problem where I have to change icons based on the state of the QPushButton (default, hover, pressed, etc.). Here is what I use to set the icon for a…
Spen-ZAR
  • 818
  • 6
  • 19
2
votes
1 answer

Right-align a button in a QTreeView column

I'm trying to align a button to the right side of a QTreeView column in PyQt, and I haven't been successful so far. setTextAlignment() didn't work, and neither did setData(3, QtCore.Qt.TextAlignmentRole, QtCore.Qt.AlignRight) (By "didn't work" I…
user3034039
  • 43
  • 1
  • 5
2
votes
1 answer

PyQt Button Selection

I have a PyQt GUI set up that has a selection of QPushButtons and a QLineEdit text box (among other things). The text box is set up so as to call a function upon returnPressed(). My problem is that when I click on the text box and put in text, one…
user3011077
  • 23
  • 1
  • 3
2
votes
1 answer

add controls(Qpushbutton and Qlineedits) on QDockwidget

I have created a blank Qdockwidget on the main dialog of my application using this: QDockWidget *Dock = new QDockWidget(this,Qt::Drawer); this->addDockWidget(Qt::RightDockWidgetArea,Dock); Now i want to add some controls like Qpushbuttons on it.…
Ashish
  • 219
  • 2
  • 6
  • 22
2
votes
2 answers

QToolButton pops up menu only when pressed and HOLD

I'm trying to implement an "open" button such that if a user presses it and holds, a menu of applications for the user to choose from will pop up; but as soon as the user releases the mouse, the menu should disappear. if the user releases the mouse…
user110
  • 315
  • 1
  • 11