qwidget

Dragging a QWidget in QT 5

筅森魡賤 提交于 2019-12-05 06:12:22
I have to make something like the iOS interface, 3x3 field of icons that can be dragged to change their position, and then remember it in an XML file. I decided to use Grid class (QWidget is parent) as a container and my own class, inherited from QWidget, as elements. Now I'm trying to learn how to perform a drag & drop for QWidget, but it seems like you are only able to drop onto a QWidget, but it's impossible to drag it. Is it impossible? How do I move this thing? Greenflow Dragging a widget isn't that easy. Plenty of coding you have to do yourself. From the Qt Docs : void MainWindow:

Qt: what layout or combination of layout should use in this case?

杀马特。学长 韩版系。学妹 提交于 2019-12-05 01:40:45
问题 I am working on a Qt Project and for this project I require to design something like this: I have designed so far in Qt Creator and I have the component ready, but when I am trying to add widget in different layouts, I am not getting the shapes I want. What should I do to make my application resizable? Catches: Sidebar has fixed width, which means for horizontal increment of window size the sidebar's horizontal width won't increase. Sidebar itself is a widget. upperbar's vertical width is

Multiple windows in a single project

杀马特。学长 韩版系。学妹 提交于 2019-12-04 22:45:57
问题 I have a requirement for my project to display two QML Window s each on one of the screen (one sender, one receiver). Both of the .qml requires me to include some Cpp models inside hence, I'm using QQmlApplicationEngine to register the Cpp models. I found out that using QWidget::createWindowContainer() I'm able to display multiple Window s for a single project. This works perfectly fine for the first QML file. The code snippets looks like this: QQmlApplicationEngine* engine = new

Widgets are not shown in basic Qt application (QMainWindow)

烈酒焚心 提交于 2019-12-04 12:48:19
I am new to Qt and I am doing some practice with simple examples. I just wanted to test my knowledge with a simple application, by coding, in which user types a text in QLineEdit widget and the text will be shown in QLabel. There is no need for it to be useful. I just want to try. While compiling the application, I get no errors. However, QLabel and QLineEdit widgets are not visible when the window is opened. My codes are here: Window.h #ifndef WINDOW_H #define WINDOW_H #include <QMainWindow> class QGridLayout; class QLabel; class QLineEdit; class Window : public QMainWindow { Q_OBJECT public:

QWidget how to receive keyPressEvent inside child widgets

给你一囗甜甜゛ 提交于 2019-12-04 08:21:28
I have one main Widget and inside this main widget I have QListWidget and two buttons. I have override the keyPressEvent inside the main widget (inherited from QWidget ). I can receive the keyPress events when focus is not on QListWidget , but when focus is inside the QListWidget I am unable to receive these keyPress events. Below is the code I have used to achieve this: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->setFocusPolicy(Qt::StrongFocus); ui->listWidget->addItem(new QListWidgetItem("Item1")); ui->listWidget->addItem

Designing GUI programmatically - good practice for nested layouts and multiple widgets (Qt)

廉价感情. 提交于 2019-12-04 06:23:44
问题 I am interested in better understanding Qt and for that I would like to see how a relatively complex example of nested layouts and multiples widgets GUI is done solely programmatically ; i.e. without the use of Qt Creator's Design. I have seen several example code demonsrating only very simple layouts and -almost- always without utilising the header files; in fact most of the examples I have seen, dump the code in the main. It is my understanding (please correct me if I am wrong) that good

Can QWidget::find find widgets from a different process?

孤街浪徒 提交于 2019-12-04 03:57:11
问题 The documentation for QWidget::winId states (among other things) "If a widget is non-native (alien) and winId is invoked on it, that widget will be provided a native handle." I'm not sure what 'alien' means in that context, but I'm choosing to ignore it for now. :) So assuming that my widget now has a valid native handle associated with it, can I then pass that native handle to another process and into QWidget::find and get a valid QWidget object back within that second process? I probably

Qt QStackedWidget Resizing Issue

北城以北 提交于 2019-12-04 03:26:50
I have a simple QStackedWidget with 3 different QWidgets in it. The minimum sizes of the QWidgets are (350x200), (200x100), and (450x450). So the problem I'm having is when I resize the QStackedWidget, it has a minimum size of the largest QWidget within it. So if I switch to the second QWidget, (which is the QWidget with the size of (200x100)), the QStackedWidget will only size down (450x450) because of the largest QWidget inside of it. I would like it to size down to fit the current QWidget being displayed, and remove that minimum size. I think that the most straightforward solution is to

Is it possible to set the opacity of qt widgets?

吃可爱长大的小学妹 提交于 2019-12-04 03:01:37
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! Miguel Fuentes Just use QGraphicsOpacityEffect in order to achieve this effect. Qt4: http://doc.qt.io/qt-4.8

How to remove QWidgets from QSplitter

与世无争的帅哥 提交于 2019-12-04 00:22:41
问题 In my app have a window splitted by a QSplitter, and I need to remove an widget. How can I do that? I can't find useful methods 回答1: Many things in Qt cannot be "traditionally" removed. Instead call hide() on it and destruct it. From QSplitter documentation: When you hide() a child its space will be distributed among the other children. It will be reinstated when you show() it again. 回答2: It's not clear to me if you want to preserve the widget and put it somewhere else, or if you want to