qwidget

How to create custom layout for widget

 ̄綄美尐妖づ 提交于 2019-12-13 06:57:54
问题 I'm trying to create a custom widget in QT that looks something like this: The red squares will be displaying an image/icon. How can I achieve this layout through coding the widget? I will need to create many of those widgets with the same layout but different values in their labels. Ideally, I will display those widgets as a list with a scrollbar in my mainwindow. But right now I'm struggling to just create the layout for those widgets through code. Any help is much appreciated. 回答1: You

QThread and GUI Thread clarification

允我心安 提交于 2019-12-13 05:22:21
问题 In the official Qt Documentation: As mentioned, each program has one thread when it is started. This thread is called the "main thread" (also known as the "GUI thread" in Qt applications). The Qt GUI must run in this thread. All widgets and several related classes, for example QPixmap, don't work in secondary thread Now, in a qt project i've tried the following code: QThread* thread = new QThread; DetectList *list = new DetectList; list->moveToThread(thread); connect(thread, SIGNAL(started())

How to prevent member QWidgets or QDialog objects taking over key events from QMainWindow once the dialog has been clicked by the mouse?

泄露秘密 提交于 2019-12-13 03:44:29
问题 So I have QMainWindow type class which described by the following code: class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: void closeEvent(QCloseEvent *);\ DimensionDialog *newResolution; Ui::MainWindow *ui; ImageInteraction *liveVideo; ImageInteraction *modifiedVideo; CameraControl *cameraControl; QPushButton *pushToTalk; QPushButton *audioSettingsSetup; AudioSettings *audioSettings; QPushButton *numberOfRunningThreads;

Why is QWidget with border and background image styling behaving different to QLabel, QDialog, …?

倖福魔咒の 提交于 2019-12-13 02:53:10
问题 I use the Qt4.8 Python binding PySide (version 1.2.2 on Python 3.3 on Windows) and I see that QWidget behaves different from QWidget derived widgets like QDialog , QLabel or QMainWindow when styling with stylesheets. In particular I observe that the attribute WA_StyledBackground must be set to show a border or a background image while a background color is set independently. In contrast for the other widgets this attribute has no influence, a border or background image is always shown.

How to interpret QFontMetrics results?

做~自己de王妃 提交于 2019-12-13 02:51:28
问题 I have a problem making sense of the values I get from QFontMetrics // 43 characters 0123456789012345678901234567890123456789012 static const QString s("The quick brown fox jumps over the lazy dog"); // Hint: basically returns w->fontMetrics(); with w being my main application window const QFontMetrics fm = CGuiUtility::currentFontMetrics(); const int w = fm.width(s); const int h = fm.height(); return QSize(w, h); With the following screen resolutions I get: ) 1920/1080: 256/16 ) 3840/2160:

Resize a QWidget containing a QVBoxLayout in runtime when contents are partially Hidden

谁说胖子不能爱 提交于 2019-12-13 00:31:58
问题 In this application, a list of HBoxLayouts is generated and put into a VBoxLayout in order to form a dynamically filled list of commands. There is a button above each sub-list which has the capability to hide the controls below it. The problem: when a sub-list is hidden, the widget which contains the broadest VBoxLayout does not change in size! The VBoxLayout then stretches to compensate. I want the container widget to shrink when it contains fewer items! It looks like this: The problem is,

How to Drag and Drop Custom Widgets?

China☆狼群 提交于 2019-12-12 15:44:40
问题 I have created my own custom widget and I want to support internal drag and drop for the widgets. I have added 4 of my custom widgets in a vertical box layout. Now i want to drag and drop the custom widgets internally. To be more clear, If i drag the last widget and drop it in the first position, then the first widget has to move to the second positon and the last widget (which is dragged) has to move to first position. (same like drag and drop of the items in the List view). Can anyone

Transitioning between menu screens with QStateMachine

泄露秘密 提交于 2019-12-11 23:42:06
问题 I am considering transitioning between menu screens in a game by using QStateMachine . However, I'm unsure how to kick off some code (e.g. show() a QWidget ) upon a transition between states occurring. I can do it quite easily with plain old signals (see commented out code), but I figure that I could probably do some fancy animation upon switching screens using transitions. Here's my code: Edit: updated as per Koying's suggestion. ApplicationWindow.h : #include <QtGui> #include <QStateMachine

How to make QWidget background with specified png file?

妖精的绣舞 提交于 2019-12-11 19:19:10
问题 MyDialog::MyDialog(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint) , _pixmap(new QPixmap(myPngFile)) { QPalette palette; palette.setBrush(this->backgroundRole(), QBrush(*_pixmap)); this->setPalette(palette); setFixedSize(_pixmap->size()); } myPngFile define the png path. The problem is the transparent part in png file showed black when I show MyDialog, how do I correct it to load myPngFile? I am using Windows platform with Qt4.8 Please

QPropertyAnimation for rotating QWidget

我是研究僧i 提交于 2019-12-11 17:11:34
问题 I'm new to Qt and I'm having some problem with QWidget rotation. I have a QPixmap inside a QLabel. What I want is to animate it with a continuous rotation by 90 degrees. I know QPropertyAnimation and I know how to use it, but I'm struggling with How to use it for rotating a QWidget . Is there any simple way to use achieve my goal and rotate the entire QLabel or the QPixmap inside it with an animation? Thank you. 回答1: This is the demo for rotation of QLabel/QPixmap with animation. it's not