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

How to include needed headers automatically in QT Creator

I have a project in QT Creator and I want that the header files be included automatically when using a new object. It's like in Eclipse : Add needed headers when invoking a new object by using Ctrl+Alt+Space : all needed headers will be…
The Beast
  • 1,629
  • 2
  • 29
  • 42
5
votes
3 answers

Set position (to right) of Qt QPushButton popup menu

I am writing a popup menu for a Qt push button widget. Whenever the push button is clicked, a menu pops up (below the push button). The popup menu is left-sided below by default. Are there any ways to make the popup menu to pop up on the right side…
Ryan
  • 279
  • 1
  • 4
  • 12
5
votes
2 answers

PyQt: Wrapping Dialog from QDesigner and Connect pushbutton

I'm starting to learn Python and PyQt. Currently I am fighting with a very basic problem about connecting signals and Slots, with Dialog forms generated form QDesigner. I want to connect a pushbutton from a QDialog. The code does not generate an…
BerndGit
  • 1,530
  • 3
  • 18
  • 47
5
votes
3 answers

c++ QPushButton signal and slot

I have a problem creating a QPushButton and linking its signal to my slots. First, I created a class with the slot: class A : public QWidget{ public slots: void handleButton(); }; There is my handleButton function in the .cpp void…
Aurimas_12
  • 109
  • 1
  • 2
  • 13
5
votes
2 answers

QPushButton setDown on click

When a QPushButton is clicked, I want it to remain pressed down until clicked again. void MainWindow::itemClicked(){ QPushButton *clickedItem = qobject_cast(sender()); qDebug() << clickedItem->isDown(); …
Quaxton Hale
  • 2,460
  • 5
  • 40
  • 71
5
votes
1 answer

How to get the row/column location of a widget in a QGridLayout?

I made an own GridPushButton class to store the buttons position in gridlayout. The parent is QPushButton. I have a problem with asking it's x and y coordinates in window (like x:654, y:768). I thought it will be inherited from base class, but it…
user3137292
  • 65
  • 1
  • 1
  • 4
5
votes
1 answer

Can I utilize Pyside clicked.connect to connect a function which has a parameter

I want to have a function in main class which has parameters not only self. class Ui_Form(object): def clearTextEdit(self, x): self.plainTextEdit.setPlainText(" ") print("Script in Textbox is Cleaned!",) x will be my…
mesutali
  • 1,655
  • 2
  • 12
  • 9
5
votes
1 answer

No icon with QStyleOptionButton

I have got a weird problem. I need to have some buttons in my QTableView. I used to use QAbstractItemView::setIndexWidget() method, but it is not very responsible when working with larger models. Therefore I decided to switch to…
Garrappachc
  • 719
  • 5
  • 19
5
votes
1 answer

Set icon on qpushbutton

I know, thats a beginners question but I have to tried to solve it with goolge / stackoverflow, but I haven't found a good answer. The problem is, I want to add a icon to a qpushbutton. But it doesnt work / the file is not found?!, where is the…
user2372976
  • 715
  • 1
  • 8
  • 19
5
votes
2 answers

QPushButton creates empty space on Mac OS X resulting in ugly layouts

I recently moved to Mac OS X and noticed that the Dialogs in one of my applications look kind of strange... I have several Dialogs that are basically a simple form that has configurable paths: Label:
Strayer
  • 3,050
  • 3
  • 30
  • 40
5
votes
1 answer

Qt - Stylesheet for disabled QPushButton under Windows 7 Basic Theme

I can change the font and font-color of a QPushButton using the StyleSheets. The Problem is that under the old Windows Theme the disabled Buttons shows a shaded font, but i dont know how to get rid of this shaded front through StyleSheets. Can…
New Moon
  • 787
  • 6
  • 21
  • 35
4
votes
1 answer

How to make a QPushButton a loading button?

Is there a way to make a loading button out of a QPushButton? I want to do something like https://coreui.io/docs/components/loading-buttons/ but in Qt. Is this possible? I would like to make a loading/progress bar out of each list widget item like…
spitfiredd
  • 2,897
  • 5
  • 32
  • 75
4
votes
1 answer

Prevent okay QPushButton from accepting dialog on press enter

In the following code, the Ok button of the dialog always seems to come into focus, thus when enter is pressed, the dialog is accepted and closes. What I am aiming for is that to have the user edit text in the line edit, and then be allowed to…
Vince W.
  • 3,561
  • 3
  • 31
  • 59
4
votes
2 answers

How to customize QPushButton to only popup menu when clicked around the arrow?

I want to add a popup menu to QPushButton, but only popup it when you click near the arrow, if you click other area on the button, it calls the slot connected in main UI. I know there is QToolButton, and you can set its ToolButtonPopupMode to…
Shuman
  • 3,914
  • 8
  • 42
  • 65
4
votes
3 answers

qt how to know that a pushbutton is clicked?

I'm trying to do a program which makes some operations with sounds. My question is that I have 3 Play pushbutton and 3 label. I want that whichever I click on the Play button, the sound whose name is in the label that is near the pushbutton should…
Enes Altuncu
  • 449
  • 2
  • 7
  • 14
1 2
3
41 42