qpushbutton

How do I prevent the enter key from closing my QDialog (Qt 4.8.1)

安稳与你 提交于 2019-12-21 07:20:09
问题 I have a QDialog with a QDialogButtonBox . The OK and Cancel buttons are active. Occasionally I disable or hide the OK button based on the state of my dialog. It seems, no matter what I do, the Enter key always activates the OK button. I really DON'T want this to happen. I have tried: Setting default and autoDefault properties to false every time I show/hide/enable/disable/whatever the button installing an event filter on the OK button to intercept key events (pressed and released) for return

How do I prevent the enter key from closing my QDialog (Qt 4.8.1)

感情迁移 提交于 2019-12-21 07:20:07
问题 I have a QDialog with a QDialogButtonBox . The OK and Cancel buttons are active. Occasionally I disable or hide the OK button based on the state of my dialog. It seems, no matter what I do, the Enter key always activates the OK button. I really DON'T want this to happen. I have tried: Setting default and autoDefault properties to false every time I show/hide/enable/disable/whatever the button installing an event filter on the OK button to intercept key events (pressed and released) for return

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

怎甘沉沦 提交于 2019-12-21 05:43:09
问题 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: <QLineEdit> <QPushButton (opens file dialog)> Label: ... The Dialog is organized in a QGridLayout, it looks fine on Ubuntu: On Mac OS X there is a big empty space below the QPushButtons row which makes the whole thing look strange: I found this bug report which was apparently silently closed:

QLabel and QPushButton align

三世轮回 提交于 2019-12-20 04:52:42
问题 I'm having a hard time aligning multiple qt widgets (label and push button). I want the widgets (colored green and red respectively) to line up. Any advice? #include <QVBoxLayout> #include <QLabel> #include <QPushButton> #include "ui_dialog.h" Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); QVBoxLayout * const layout = new QVBoxLayout(ui->scrollAreaWidgetContents); for(int i=0; i!=100; ++i) { QLabel *label = new QLabel(); layout->addWidget(label);

Qt table widget, button to delete row

巧了我就是萌 提交于 2019-12-13 14:03:02
问题 I have a QTableWidget and for all rows I set a setCellWidget at one column to a button. I would like to connect this button to a function that delets this row. I tried this code, which does not work, because if I simply click my button I do not set the current row to the row of the button. ui->tableWidget->insertRow(ui->tableWidget->rowCount()); QPushButton *b = new QPushButton("delete",this); ui->tableWidget->setCellWidget(ui->tableWidget->rowCount()-1,0,b); connect(d,SIGNAL(clicked(bool))

Qt custom QPushButton clicked signal

让人想犯罪 __ 提交于 2019-12-13 00:53:56
问题 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 is I am new to Qt and could use some direction. connect(&fretBoardButton[string][fret], SIGNAL(clicked()), this, SLOT (testSlot())); 回答1: If you use the C++11 connection syntax you can use a lambda with calls testSlot with your string and fret

How to show the menu in QPushButton without blocking?

一曲冷凌霜 提交于 2019-12-11 12:42:28
问题 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 menu in the top left corner of the screen. How can I programmatically make the menu show up properly positioned, and without blocking? 回答1: QMenu is QWidget . So you can call move() before show() . 回答2: You can use void QMenu::popup ( const QPoint

PySide: QPushButton stays highlighted after pressing it

↘锁芯ラ 提交于 2019-12-11 03:57:07
问题 In my tool, when the user pushes a button a popup window is created. My issue is that the button that the user presses to bring up the window stays highlighted (as if I have my mouse over it) on popup creation and remains that way even after the popup is deleted. I actually like this highlight while the popup is active (it visually connects the window to the popup which is nice), but I'd like it to go away when the window is deleted. Below is an example to clarify what's happening: If I click

Set position (to right) of Qt QPushButton popup menu

╄→尐↘猪︶ㄣ 提交于 2019-12-09 12:55:47
问题 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 below the push button? There is no set position function, so I wonder if there is some sophisticated way of doing it? Here is some code (for popup menu): QMenu *menuMode = new QMenu(this); min = menu ->addAction("In"); mout = menu ->addAction("out"

Set CSS in QPushButton's subclass's constructor

心不动则不痛 提交于 2019-12-09 07:39:26
I'm creating my custom push button class by subclassing QPushButton . However for some reason setting that class's CSS in its constructor has no effect; I have to do it in for example paintEvent , then everything is fine. I could just have a global .qss file and set it for the entire application, but I want the class to manage its own styles. Why doesn't my approach work? The code: custompushbutton.h class CustomPushButton: public QPushButton { Q_OBJECT public: explicit CustomPushButton(QWidget *parent = 0); ~CustomPushButton() = default; }; custompushbutton.cpp CustomPushButton: