qwidget

QVideoWidget: Video is cut off

孤街醉人 提交于 2019-12-10 11:09:54
问题 I want to play a video in a Qt Application. This is my code so far: #include <QApplication> #include <QWidget> #include <QMediaPlayer> #include <QVideoWidget> #include <QUrl> #include <iostream> using namespace std; const int WIDTH = 1280; const int HEIGHT = 720; int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget window; window.resize(WIDTH, HEIGHT); window.setWindowTitle("Video Test"); window.show(); QMediaPlayer *player = new QMediaPlayer(); player->setMedia(QUrl:

How can I get access to a QMessageBox by QTest

一曲冷凌霜 提交于 2019-12-10 10:37:24
问题 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?

Qt Increase QTabWidget's QTabBar size

僤鯓⒐⒋嵵緔 提交于 2019-12-09 14:05:42
问题 I need to make the tabs that I have oriented at the bottom of my QTabWidget larger. We'll be using a touch-screen, so the default sizes are a little too small. I see no easy way to do this (currently seeing no good way to even do it at all. The only methods pertaining to the QTabBar that I see in QTabWidget are protected, and I don't see a need to inherit from the class other than for this express purpose). Question: What I'd like to do is to just set the QTabBar to a certain specific size.

Is there a way to add a QWidget to a QMenu in QtCreator

淺唱寂寞╮ 提交于 2019-12-09 09:58:33
问题 I'm creating a text editor and I'd like to put the QComboBox in the QMenu . I didn't find any method inside the QMenu that handled such a thing. The closest is QMenu::addAction() . I was wondering of getting around this hurdle. Thanks! 回答1: You have to subclass QWidgetAction and then simply call the addAction to your menu. Example code for Spin Box Action with a label class SpinBoxAction : public QWidgetAction { public: SpinBoxAction (const QString& title) : QWidgetAction (NULL) { QWidget*

Qt - Clear all widgets from inside a QWidget's layout

可紊 提交于 2019-12-09 03:02:32
问题 I have a QWidget in a dialog. Over the course of the program running, several QCheckBox * objects are added to the layout like this: QCheckBox *c = new QCheckBox("Checkbox text"); ui->myWidget->layout()->addWidget(c); This works fine for all the checkboxes. However, I also have a QPushButton called "clear" in my dialog, which when it is pressed should empty everything out of myWidget, leaving it blank like it was before any of the QCheckboxes were added. I've been looking around online and in

Qt: shadow around window

a 夏天 提交于 2019-12-08 23:54:24
问题 I can add shadow to widget: QGraphicsDropShadowEffect *bodyShadow = new QGraphicsDropShadowEffect; bodyShadow->setBlurRadius(9.0); bodyShadow->setColor(QColor(0, 0, 0, 160)); bodyShadow->setOffset(4.0); ui->widget->setGraphicsEffect(bodyShadow); But this shadow will be only at left and down. I need shadow around widget. How to add this? 回答1: You can create your custom effect. I'll share an implementation that works. customshadoweffect.h #ifndef CUSTOMSHADOWEFFECT_H #define CUSTOMSHADOWEFFECT

How keep a QWidget always on top?

蓝咒 提交于 2019-12-08 16:55:27
问题 I have two buttons on my QMainWindow. One to btnShowKb and another btnHideKb. When i press btnShowKb it shows an QWidget. I want this QWidget always to be on top of all windows till I press btnHideKb. When its on top, I want both QWidget and QMainWidget be activated. Can anybody suggest on this? 回答1: Setting the setWindowFlags() with Qt::WindowStaysOnTopHint is meant to help. https://doc.qt.io/archives/qt-4.7/qt.html#WindowType-enum https://doc.qt.io/archives/qt-4.7/widgets-windowflags.html

QUiLoader widget not showing if loaded in derived QWidget

百般思念 提交于 2019-12-08 12:06:06
问题 Widget::Widget(QWidget *parent) : QWidget(parent) { file.open(QFile::ReadOnly); QWidget *w = loader.load(&file); // MyWidget *w = new MyWidget(loader.load(&file)); vLayout.addWidget(w); file.close(); vLayout.addWidget(&bt); } The code above produces the image above. But I would like to do something with the widget just loaded, that's why I derived MyWidget from QWidget . And there seems to be the problem. If I replace QWidget by MyWidget then it doesn't show there anymore. The code below

Draw on custom widget after it's drawing

纵然是瞬间 提交于 2019-12-08 04:16:33
问题 I have a custom widget, which inherits QWidget. It has own paintEvent and I cannot change it. So I want to use such a widget in my dialog object, but I need to draw some graphics on it after it draws its own graphics (that widget draws video frames on it, an I need to draw some lines over it). Can I draw every time after the paintEvent of that widget? I used installEventFilter and caught the event wuth type Qt::Paint, but I canoont see anything I've drown. Is there any other way? 回答1: You can

PyQt QWidget in QAbstractListModel gets deleted with QSortFilterProxyModel

99封情书 提交于 2019-12-08 02:03:51
问题 I need to populate a listview with widgets, then have a custom proxyfilter work with it. Without the filter it works great, when active it seems to delete the widgets attach to the model. It shows up fine showing all items, filtering works but when erasing the filter, when hidden widgets should be shown again following error gets thrown: custom_widget.setGeometry(option.rect) RuntimeError: underlying C/C++ object has been deleted Tried not using QVariant and going the internalPointer route