qwidget

How can I get access to a QMessageBox by QTest

醉酒当歌 提交于 2019-12-06 03:47:44
I am creating some automated GUI tests in my application using QTest . I can access the widgets from my application using the command: savePushButton = mainWindow->findChild<QPushButton *>("savePushButton"); It is working fine, but now I have to click on the OK button of a QMessageBox . I created the QMessageBox in my application like this: if( something_wrong ) { QMessageBox::warning(new Widget(), "Title", "Something wrong!"); } How can I have access to this QMessageBox , and its buttons? I found a solution on the following link: http://www.qtcentre.org/threads/31239-Testing-modal-dialogs

How can I print a QWidget in Qt?

本秂侑毒 提交于 2019-12-06 03:47:43
I need to know how to print a QWidget as a PDF file. The Widget (QDialog) contains a lot of labels, some QPlainTextEdit and a background image. The Dialog shows a receipt with all of its field already filled. I already tried using QTextDocument and html for this purpose, but the complexity of the receipt(lots of image and format customisation) makes the html output completely messed up. This is the document. Receipt image You have to use QPrinter and this is the object that you must use and requires QPainter to draw the widget in QPrinter . int main(int argc, char *argv[]) { QApplication a

Qt Designer how to change background

只愿长相守 提交于 2019-12-06 00:45:54
问题 This is an repost. I am kind of new in QtDesigner and wanted to do something about the uglyness of just some buttons. All i have done yesterday was looking on the internet on how to change the background color of a screen in Qt Designer. How to change the color of a button and how to make it flow into another color on the sides. Guess what. I found nothing. I hope that some of you die-hard coders know what i need.. EDIT 1: What i mean with a color flowing into another: Here pink flows into

Is it possible to set the opacity of qt widgets?

ε祈祈猫儿з 提交于 2019-12-05 21:09:33
问题 I know that there is a function QWidget::setWindowOpacity(qreal level) but as written in the documentation this does only work for windows. Is there a way to make widgets that are lying inside layouts opaque too? What I'm trying to do is an animation where widgets are fading in. I once did that with a preferences-dialog and there it worked. So do you think there is a way or a work-around to achieve opacity for widgets inside layouts? How would you do that? Thanks in advance! 回答1: Just use

QWidget / X11: Prevent window from beeing activated/focussed by mouse clicks

一个人想着一个人 提交于 2019-12-05 17:08:24
I would like to develop a system-wide onscreen keyboard in Qt/QML. Injecting key-events via xlib works fine. My problem now: If a keyboard-button is clicked, the window with the selected input field will lose the focus. In consequence, the key event will not be delivered to the previously selected input field. So does anybody know how to prevent a QWidget from beeing activated/focussed by mouse-clicks? Every hint is welcome and a code examples would be great! Thank you very much in advance, Frime 来源: https://stackoverflow.com/questions/29097363/qwidget-x11-prevent-window-from-beeing-activated

QTreeWidget editItem fails with “edit: editing failed”

余生长醉 提交于 2019-12-05 15:22:01
I have a QTreeWidgetItem added to a QTreeWidget : QTreeWidgetItem* item = new QTreeWidgetItem(ui->trwPairs); item->setFlags(item->flags() | Qt::ItemIsEditable); If the item is edited, I want to do a few checks on the new value: Pairs::Pairs(QWidget *parent) : QWidget(parent), ui(new Ui::Pairs) { ui->setupUi(this); connect(this->ui->trwPairs, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(Validate(QTreeWidgetItem*,int))); } void Pairs::Validate(QTreeWidgetItem* item, int column) { if (item->text(column).toInt() < 1) { QMessageBox::critical(this, "Error", QString("Node ID ") + item->text

Need something like a finished-signal from QWidget

房东的猫 提交于 2019-12-05 12:58:45
问题 I'm searching for something like the finished-signal from QDialog , only for QWidget . The reason is, I disable my toolbar once the widget pops up (which isn't a problem at all) and I want the toolbar to be enabled again, once the widget is closed. I also can't override the close-Event of that widget, because then we would have GUI-code in business-classes. 回答1: You can set the widget to be deleted on close, and then listen to its destroyed signal: widget->setAttribute( Qt::WA_DeleteOnClose )

QScrollArea not working as expected with QWidget and QVBoxLayout

帅比萌擦擦* 提交于 2019-12-05 11:26:31
So I have this QFrame which is the parent widget (represented by this in the code). In this widget, I want to place a QWidget at 10 px from top (and 10 px from bottom, as a result of which it will have a height of 140px, whereas parent is 160px). The QWidget will have a number of custom buttons inside it in a vertical layout, in a scroll area, so that when the height of the buttons combined exceeds the QWidget's height (140px), scroll sets in automatically. Because the scroll is not for the entire parent widget, but only for a child widget, the scroll should apply only to the child widget here

Resize QStackedWidget to the page which is opened [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-05 10:33:31
This question already has answers here : Qt QStackedWidget Resizing Issue (3 answers) Closed 5 years ago . I want my QStackedWidget to resize to the page which is opened. I got a lot of widgets attached to the first page, but the rest pages have only one button. So they stay so big, and the first page is ok. How can I make my QStackedWidget to have the size of the page being viewed. The reason why i want to do this is that I have three different options, and after that I have other things. If I change to the mode where there is a button and then a lot of white space, I don´t see why doesn´t it

active resizing of widgets inside mainwindow

早过忘川 提交于 2019-12-05 09:06:37
I have a few widgets in a main window. i want the user to be able to resize the widgets inside the window as they please, just like how one would resize the main window. Do I have to make a layout container to enable this? or ....layout? Buh the layout contains are static once the window is rendered. In the picture the three widgets should be enable with resizing such that the user can drag their sides/corners to expand or minimize the widget size. One thing you could do is to use some QSplitter 's though it isn't directly as nuanced as you pointed out. Have a look at the image (you can drag