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

How to customize text on Qpushbutton using QPalette?

How to set font, size and color for the Text of QPushButton in Qt5.6.1 using QPalette? As I am curious to know how we can set these properties without using QStyleSheet in Qt. Also how we can set hex code of color in QT. Please suggest any way to do…
Avi
  • 31
  • 2
  • 7
2
votes
1 answer

Iterate QPushButton

I am using PyQt4. I have a QPushButton and now I want to Iterate it. On button click, it should load data from csv file into QTableWidget. But I want only one case to display at a time. For example csv has 1000 rows excluding headers. Now it should…
2
votes
1 answer

PyQt QPushButton signal handling

I have a repeat python function and a test.ui which has only one push-button. My doubt is how to loop the same function exactly once for every time the button is clicked. Because for me whenever I…
2
votes
1 answer

PyQT: PushButton receives commands while disabled

I came across this problem and tried to break it down to the simplest code I could imagine: I created a GUI using Qt Designer V4.8.7 that only consists of a single pushButton with all default settings. It's called 'Test2.ui'. When the button is…
Delf
  • 25
  • 1
  • 4
2
votes
2 answers

How to disable a Button unless a Edit Field isn't empty?

I've got a QLineEdit field and a QPushButton. The button should be disabled as long the QLineEdit is empty. How to do that?
eco
  • 321
  • 2
  • 4
  • 11
2
votes
1 answer

How to create a QPushButton with the text displayed over the icon?

I am trying to create a QPushButton in my project such that the text shows on top of the custom button image or icon. I tried the below methods: imagePath = path; QPixmap pixmap(imagePath); QIcon…
Sam
  • 113
  • 5
  • 13
2
votes
1 answer

QT - How to get QPushButton Active On/Off Icon Name

I would specifically like to get the active on/off name of the icon for the qPushButton. I tried to log first the icon name like on my code but the output was always empty even if I tried to programmatically make an icon, any idea how to solve…
Garlen
  • 426
  • 1
  • 5
  • 17
2
votes
2 answers

Is it possible to store a QPushButton in a QVariant?

I'd like to know if it's possible to store a QPushButton in a QVariant. More precisely, I am trying to use it in a QStandardItemModel with the function setData. Here's what I want to do : QPushButton* button = new…
IAmInPLS
  • 4,051
  • 4
  • 24
  • 57
2
votes
2 answers

QTreeWidget - width of column with widget

I have QTreeWidget with two columns. The first column is the text, and the second is QPushButton. I can not specify the size of buttons and the size of the second column. When you try to set the size of the column of content, the second column…
Vika
  • 153
  • 3
  • 4
  • 12
2
votes
2 answers

Qt custom QPushButton clicked signal

I want to send two integers, string and fret, to a SLOT that will process the location of the button that was pressed. The SIGNAL and SLOT argument have to match so I am thinking I need to reimplement the QPushButton::clicked event method. Problem…
Ritchie Shatter
  • 185
  • 1
  • 4
  • 14
2
votes
2 answers

mouse press event inside Qpushbutton in QT

I am using qt creator to make a calculator. There is a default mainwindow form that has the gui. And in mainwindow.cpp, i have set setMouseTracking(true) , to get mouse coordinates when clicked. But i get the mouse coordinates only when a click is…
sid0893
  • 41
  • 1
  • 2
  • 5
2
votes
1 answer

QMenu: How to customize the menu items of QMenu

I want to build a dropdown list control with QPushButton and QMenu like below: QPushButton* menuBt = new QPushButton("Please select"); menuBt->setFlat(true); QMenu* menu = new QMenu(); menuBt->setMenu(menu); QWidgetAction* wa1 = new…
ldlchina
  • 927
  • 2
  • 12
  • 31
2
votes
2 answers

QT/c++ call class function with pushbutton

i have an UI with two buttons. My first button read an xml file. The second button should create an window an show a circle. I have a mainwindow.h and a circle.h. Now i want to start my circle function with a pushbutton click. My circle…
user3676560
  • 151
  • 2
  • 15
2
votes
1 answer

How to increase the clickable area of a QPushButton in Qt?

The Back button in the top left corner of my touch user interface is a little hard to press on a resistive touchscreen, because the touch events are not so precise at the borders of the screen. The visual size of the button can't really be increased…
Fritz
  • 1,293
  • 15
  • 27
2
votes
1 answer

QPushButton 100% height of QGridLayout's cell

qroupBoxButtons = new QGroupBox(); QGridLayout *layout = new QGridLayout; pushButtonPlus = new QPushButton( tr( "+" ) ); layout -> addWidget( pushButtonPlus, 1, 1 ); /* add another elements to layout */ layout -> setColumnStretch( 1, 25…
ostapische
  • 1,572
  • 2
  • 12
  • 26