QQuickWidgets embedded in QTabWidget container, crashes upon rendering custom OpenGL code, via QML, QQuickItem and QSGNode.
The crash or scene flickering happens when you click on the other tabs on the QTabWidget and return back to the rendering tab.
QQuickWidget* m_quickWidget = new QQuickWidget;
QTabWidget *tabs = new QTabWidget(this);
tabs->addTab(m_quickWidget,"TAB Rendering");
tabs->addTab(new QWidget(),"TAB 1");
m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView );
m_quickWidget->setSource(source);
setCentralWidget(tabs);
The above scenario runs peacefully without any problem when using QQuickViews:
QTabWidget *tabs = new QTabWidget(this);
QWidget* vw = QWidget::createWindowContainer(m_quickWidget);
tabs->addTab(vw,"TAB Rendering");
tabs->addTab(new QWidget(),"TAB 1");
I have attached a qt project for emphasizing the problem
back trace for more info
Hi we have seen similar things including the black flickering, however 5.5 seems to have made that black flicker go away. Have you tried that?
Also, I would recommend that you post it on the Qt bug tracker so that someone from the Qt dev team can recreate and fix the problem.
Related
I am trying to learn QT with visual studio. My development environment is VS2015 with QT designer. I am trying to do the following tutorial.
http://www.bogotobogo.com/Qt/Qt5_QMainWindow_QAction_ImageViewer_B.php
essentially the tutorial displays an image with Qlabel and QScrollArea. If I create the widgets with code (using visual studio) the program seems to work.
imageLabel = new QLabel;
imageLabel->setBackgroundRole(QPalette::Base);
imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
imageLabel->setScaledContents(true);
scrollArea = new QScrollArea;
scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(imageLabel);
setCentralWidget(scrollArea);
However, then I tried to do the same with QT Designer. When I dragged a ScrollArea from QT Designer, I notices that it also created a QWidget called "scrollAreaWidgetContents". Then when I created the QLabel, Label was created under "scrollAreaWidgetContents" widget. I then tried to display the image using the following code.
ui->label->setBackgroundRole(QPalette::Base);
ui->label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
ui->label->setScaledContents(true);
ui->scrollArea->setBackgroundRole(QPalette::Dark);
ui->scrollArea->setWidget(ui->scrollAreaWidgetContents);
ui->scrollArea->setWidgetResizable(true);
ui->scrollAreaWidgetContents->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
//ui->scrollArea->setWidget(ui->label);
setCentralWidget(ui->scrollArea);
The problem with this is that the scroll Bars never appears. See the attached
Then I uncommented "ui->scrollArea->setWidget(ui->label);" line and then the program compiles but crashes. So, how do I make the scrollBars appear with QT Designer? What am I doing wrong.
Thanks for the help
I am using Qt in Visual Studio to get an interface with buttons and knobs etc. I am using this SkinnedDial class - http://dronecolony.com/2012/12/11/customized-qdial-with-qss-support/ , to get a QDial with a custom image. But the problem is that while the other controls are showing the focus frame when I tab over them, this control does not show the focus - for instance button shows the rectangle, but nothing shows up for the dial. Here's the code segment for the dial -
SkinnedDial *myDial;
...
myDial = new SkinnedDial(this);
myDial->setRange(-100, 100);
QPixmap *bg = new QPixmap();
bg->load("C:/Current/dial.png");
QPixmap *nl = new QPixmap();
nl->load("C:/Current/needl.png");
myDial->setBackgroundImage(*bg);
myDial->setNeedleImage(*nl);
myDial->setMaxAngle(100);
I am new to Qt and C++ and I'm not sure how to solve this problem.
I'm writing a Qt application which uses mpv for playing different videos.
QWidget is used to show video content. I also have custom dock with controls for switching video channels, changing position, etc.
I want to have dock appearing after a click on the screen and disappearing on timer event. It all works fine, except from the fact, that QWidget used for mpv is not receiving QMouseEvent. On the contrast same event works fine for main window. Basically dock appears only if you click on visible part of main window and not on mpv Qwidget.
I assume it is because mpv has internal support for keybindings. I've tried to disable them by setting "input-default-bindings" to "no", but it didn't help.
mpv_set_option_string(mpv, "input-default-bindings", "no");
Can anybody help with that?
Does anybody know how to configure keybindings for mpv (I can't find any example in documentation)?
Maybe there is a workaround for it?
Thanks a lot.
You can use a transparent widget in front of video area to receive and redirect QMouseEvent to your custom dock. Though this is not a beautiful solution... How to create such widget is described here.
I want to open a new window aligned with the try icon (as the built-in volume control does)! :/
I found something about QRect QSystemTrayIcon::geometry()
But idk how to use it
I would recommend using Qt::Popup flags on your widget.
https://forum.qt.io/topic/6632/use-of-popup-window
QWidget* popupWidget = new QWidget();
popupWidget->setWindowFlags(Qt::Popup);
Pretty much anything else has a lot of corner cases that are hard to cover, like if your window is too tall, goes off the edge of the screen, etc.
Hope that helps.
Our application uses Qt's Graphics View framework to load the html pages. QGraphicsWebView loads local html page which is black background. But always observed the white screen while launching the application. I have tried setting black background for both QGraphicsView and QGraphicsScene. Nothing worked for me.
Here's the sample code for your reference.
MainWindow which inherited from QMainWindow class
mGraphicsScene = new QGraphicsScene(this);
mGraphicsView = new QGraphicsView(mGraphicsScene);
mGraphicsView->setViewport(new QGLWidget(this));
mGraphicsWebView = new QGraphicsWebView;
mGraphicsWebView->setUrl(QUrl("https://www.google.co.in/"));
mGraphicsScene->addItem(mGraphicsWebView);
setCentralWidget(mGraphicsView);
Is there any way to avoid white screen of the application?
Best Regards,
Pratap
Try next. Why did you see white? Because item already added, but page not loaded, so you see white(blank) item without page. Set to your scene some black pixmap, connect loadFinished signal to special slot, where you add item to your scene. In this case scene will be black, but when page will be loaded, your slot will add this on scnen and you will see only page.
mGraphicsScene = new QGraphicsScene(this);
mGraphicsScene->addItem(new QGraphicsPixmapItem(QPixmap("G:/2/qt.jpg")));
mGraphicsView = new QGraphicsView(mGraphicsScene);
mGraphicsView->setViewport(new QGLWidget(this));
mGraphicsWebView = new QGraphicsWebView;
mGraphicsWebView->setUrl(QUrl("https://www.google.co.in/"));
connect(mGraphicsWebView,SIGNAL(loadFinished(bool)),this,SLOT(slotLoaded()));
//mGraphicsScene->addItem(mGraphicsWebView);
mGraphicsView->resize(1000,700);
mGraphicsView->show();
Slot:
void MainWindow::slotLoaded()
{
mGraphicsScene->addItem(mGraphicsWebView);
}
For example black pixmap which was created by code:
QPixmap black(1000,700);
black.fill(Qt::black);
mGraphicsScene = new QGraphicsScene(this);
mGraphicsScene->addItem(new QGraphicsPixmapItem(black));
When application start:
As you can see, all is black, when page was loaded:
As you can see, it is normal page. It is not very beautiful because I use fast settings and resize window and so on, but you set graphicsview as central widget, do it will be more beautiful.
Thank you very much for the response.
I have tried your solution and also observed white screen while launching the application on Windows
I found the culprit is mGraphicsWebView->setUrl(QUrl("https://www.google.co.in/")); This is blocking all other widgets on the scene. So I have added a singleShot timer and kept this statement under that.
//QTimer::singleShot(100, this, SLOT(loadUrl())); Then it works fine.
Please let me know if you have any better idea.