Skip to content
QtWS25 Call for Papers
  • 0 Votes
    4 Posts
    43 Views
    Axel SpoerlA

    Qt 5.11 is no longer supported. No point in using it, when everything works on 5.15.

  • Can't set background color

    Unsolved General and Desktop
    4
    0 Votes
    4 Posts
    471 Views
    SGaistS

    Where are you using that painter ?

  • 0 Votes
    6 Posts
    510 Views
    Vivek_AV

    @Christian-Ehrlicher @JonB Solved . By creating a seperate worker.cpp file and connected RTLSClient signal to worker slot, now data is inserting to mongodb very fast without freezing GUI.
    Thanks ..

  • 0 Votes
    4 Posts
    427 Views
    M

    @timob256 said in Is stroke the text (Circle text ):

    cannot align the bypass line with the inner line

    Sorry, i don't understand.

    If you want the background to be green, add a fillPath before stroke path:

    painter.fillPath(path,Qt::green); painter.strokePath(path,pen);
  • 0 Votes
    1 Posts
    195 Views
    No one has replied
  • 0 Votes
    2 Posts
    127 Views
    Christian EhrlicherC

    Wouldn't it be better to ask the C4 engine developers how it could work? When their API provides a QWidget or QWindow all is fine. If they need a OpenGL context to work in, it will also work. But I don't think we can answer this.

  • 0 Votes
    2 Posts
    337 Views
    JonBJ

    @timob256
    Cross-referenced from your other thread at https://forum.qt.io/topic/132655/how-to-embed-ogre3d-in-qt5-as-a-widget.

    A QWindow is not derived from a QWidget, so, no, you cannot put a QLayout on it. Docs say:

    The QWindow class represents a window in the underlying windowing system.

    So you do not set extra buttons or charts or whatever on a QWindow.

    You may know better than I, and I don't know how it relates to your "Ogre" situation, but you may want to read through What is the difference between a QWindow and QWidget and maybe Introducing QWidget::createWindowContainer() too. Qt: layouts with a Qwidget window container talks about layouts too.

  • 0 Votes
    6 Posts
    701 Views
    JonBJ

    @timob256 said in How to embed Ogre3d in qt5 as a widget:

    QWindows not unit setLayout ? install in element, not posible.

    Don't know what this means.

    this->setLayout(gl_layaout[3]); // this not work !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Don't know what this means.

    All your widgets are created with parent as their parent, instead of this. Since I wrote earlier

    But why are you using parent here? Shouldn't it be this?

    do you not think this applies to your case? Why?

    You are creating your widgets with a parent of parent of QTOgreWindow, and then this->setLayout(gl_layaout[3]); setting the layout on this. I don't get what you are trying to do or why.

    UPDATE
    I see you have now taken this question to https://forum.qt.io/topic/132674/how-do-i-put-a-qlayout-in-a-qwindow. It's always helpful to others if you cross-reference posts like this.

    I see now that my "But why are you using parent here? Shouldn't it be this?" is not applicable to QWindow. I will post into your other thread.

  • 0 Votes
    9 Posts
    930 Views
    timob256T

    main.cpp

    #include "widget.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); }

    QTOgreWindow.cpp

    #include "QTOgreWindow.h" #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0) #include <Compositor/OgreCompositorManager2.h> #endif /* Note that we pass any supplied QWindow parent to the base QWindow class. This is necessary should we need to use our class within a container. */ QTOgreWindow::QTOgreWindow(QWindow *parent) : QWindow(parent) , m_update_pending(false) , m_animating(false) , m_ogreRoot(NULL) , m_ogreWindow(NULL) , m_ogreCamera(NULL) , m_cameraMan(NULL) { setAnimating(true); installEventFilter(this); m_ogreBackground = Ogre::ColourValue(0.0f, 0.5f, 1.0f); } /* Upon destruction of the QWindow object we destroy the Ogre3D scene. */ QTOgreWindow::~QTOgreWindow() { if (m_cameraMan) delete m_cameraMan; delete m_ogreRoot; } /* In case any drawing surface backing stores (QRasterWindow or QOpenGLWindow) of Qt are supplied to this class in any way we inform Qt that they will be unused. */ void QTOgreWindow::render(QPainter *painter) { Q_UNUSED(painter); } /* Our initialization function. Called by our renderNow() function once when the window is first exposed. */ void QTOgreWindow::initialize() { /* As shown Ogre3D is initialized normally; just like in other documentation. */ #ifdef _MSC_VER m_ogreRoot = new Ogre::Root(Ogre::String("plugins" OGRE_BUILD_SUFFIX ".cfg")); #else m_ogreRoot = new Ogre::Root(Ogre::String("plugins.cfg")); #endif Ogre::ConfigFile ogreConfig; /* Commended out for simplicity but should you need to initialize resources you can do so normally. ogreConfig.load("resources/resource_configs/resources.cfg"); Ogre::ConfigFile::SectionIterator seci = ogreConfig.getSectionIterator(); Ogre::String secName, typeName, archName; while (seci.hasMoreElements()) { secName = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator i; for (i = settings->begin(); i != settings->end(); ++i) { typeName = i->first; archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); } } */ const Ogre::RenderSystemList& rsList = m_ogreRoot->getAvailableRenderers(); Ogre::RenderSystem* rs = rsList[0]; /* This list setup the search order for used render system. */ Ogre::StringVector renderOrder; #if defined(Q_OS_WIN) renderOrder.push_back("Direct3D9"); renderOrder.push_back("Direct3D11"); #endif renderOrder.push_back("OpenGL"); renderOrder.push_back("OpenGL 3+"); for (Ogre::StringVector::iterator iter = renderOrder.begin(); iter != renderOrder.end(); iter++) { for (Ogre::RenderSystemList::const_iterator it = rsList.begin(); it != rsList.end(); it++) { if ((*it)->getName().find(*iter) != Ogre::String::npos) { rs = *it; break; } } if (rs != NULL) break; } if (rs == NULL) { if (!m_ogreRoot->restoreConfig()) { // if (!m_ogreRoot->showConfigDialog()) // OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, // "Abort render system configuration", // "QTOgreWindow::initialize"); } } /* Setting size and VSync on windows will solve a lot of problems */ QString dimensions = QString("%1 x %2").arg(this->width()).arg(this->height()); rs->setConfigOption("Video Mode", dimensions.toStdString()); rs->setConfigOption("Full Screen", "No"); rs->setConfigOption("VSync", "Yes"); m_ogreRoot->setRenderSystem(rs); m_ogreRoot->initialise(false); Ogre::NameValuePairList parameters; /* Flag within the parameters set so that Ogre3D initializes an OpenGL context on it's own. */ if (rs->getName().find("GL") <= rs->getName().size()) parameters["currentGLContext"] = Ogre::String("false"); /* We need to supply the low level OS window handle to this QWindow so that Ogre3D knows where to draw the scene. Below is a cross-platform method on how to do this. If you set both options (externalWindowHandle and parentWindowHandle) this code will work with OpenGL and DirectX. */ #if defined(Q_OS_MAC) || defined(Q_OS_WIN) parameters["externalWindowHandle"] = Ogre::StringConverter::toString((size_t)(this->winId())); parameters["parentWindowHandle"] = Ogre::StringConverter::toString((size_t)(this->winId())); #else parameters["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned long)(this->winId())); parameters["parentWindowHandle"] = Ogre::StringConverter::toString((unsigned long)(this->winId())); #endif #if defined(Q_OS_MAC) parameters["macAPI"] = "cocoa"; parameters["macAPICocoaUseNSView"] = "true"; #endif /* Note below that we supply the creation function for the Ogre3D window the width and height from the current QWindow object using the "this" pointer. */ m_ogreWindow = m_ogreRoot->createRenderWindow("QT Window", this->width(), this->height(), false, &parameters); m_ogreWindow->setVisible(true); /* The rest of the code in the initialization function is standard Ogre3D scene code. Consult other tutorials for specifics. */ #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0) const size_t numThreads = std::max<int>(1, Ogre::PlatformInformation::getNumLogicalCores()); Ogre::InstancingThreadedCullingMethod threadedCullingMethod = Ogre::INSTANCING_CULLING_SINGLETHREAD; if (numThreads > 1)threadedCullingMethod = Ogre::INSTANCING_CULLING_THREADED; m_ogreSceneMgr = m_ogreRoot->createSceneManager(Ogre::ST_GENERIC, numThreads, threadedCullingMethod); #else m_ogreSceneMgr = m_ogreRoot->createSceneManager(Ogre::ST_GENERIC); #endif m_ogreCamera = m_ogreSceneMgr->createCamera("MainCamera"); m_ogreCamera->setPosition(Ogre::Vector3(0.0f, 0.0f, 10.0f)); m_ogreCamera->lookAt(Ogre::Vector3(0.0f, 0.0f, -300.0f)); m_ogreCamera->setNearClipDistance(0.1f); m_ogreCamera->setFarClipDistance(200.0f); m_cameraMan = new OgreQtBites::SdkQtCameraMan(m_ogreCamera); // create a default camera controller #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0) createCompositor(); #else Ogre::Viewport* pViewPort = m_ogreWindow->addViewport(m_ogreCamera); pViewPort->setBackgroundColour(m_ogreBackground); #endif m_ogreCamera->setAspectRatio( Ogre::Real(m_ogreWindow->getWidth()) / Ogre::Real(m_ogreWindow->getHeight())); m_ogreCamera->setAutoAspectRatio(true); Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); createScene(); m_ogreRoot->addFrameListener(this); } void QTOgreWindow::createScene() { /* Example scene Derive this class for your own purpose and overwite this function to have a working Ogre widget with your own content. */ m_ogreSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f)); #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0) Ogre::Entity* sphereMesh = m_ogreSceneMgr->createEntity(Ogre::SceneManager::PT_SPHERE); #else Ogre::Entity* sphereMesh = m_ogreSceneMgr->createEntity("mySphere", Ogre::SceneManager::PT_SPHERE); #endif Ogre::SceneNode* childSceneNode = m_ogreSceneMgr->getRootSceneNode()->createChildSceneNode(); childSceneNode->attachObject(sphereMesh); Ogre::MaterialPtr sphereMaterial = Ogre::MaterialManager::getSingleton().create("SphereMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true); sphereMaterial->getTechnique(0)->getPass(0)->setAmbient(0.1f, 0.1f, 0.1f); sphereMaterial->getTechnique(0)->getPass(0)->setDiffuse(0.2f, 0.2f, 0.2f, 1.0f); sphereMaterial->getTechnique(0)->getPass(0)->setSpecular(0.9f, 0.9f, 0.9f, 1.0f); //sphereMaterial->setAmbient(0.2f, 0.2f, 0.5f); //sphereMaterial->setSelfIllumination(0.2f, 0.2f, 0.1f); sphereMesh->setMaterialName("SphereMaterial"); childSceneNode->setPosition(Ogre::Vector3(0.0f, 0.0f, 0.0f)); childSceneNode->setScale(Ogre::Vector3(0.01f, 0.01f, 0.01f)); // Radius, in theory. #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0) Ogre::SceneNode* pLightNode = m_ogreSceneMgr->getRootSceneNode()->createChildSceneNode(); Ogre::Light* light = m_ogreSceneMgr->createLight(); pLightNode->attachObject(light); pLightNode->setPosition(20.0f, 80.0f, 50.0f); #else Ogre::Light* light = m_ogreSceneMgr->createLight("MainLight"); light->setPosition(20.0f, 80.0f, 50.0f); #endif } #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0) void QTOgreWindow::createCompositor() { /* Example compositor Derive this class for your own purpose and overwite this function to have a working Ogre widget with your own compositor. */ Ogre::CompositorManager2* compMan = m_ogreRoot->getCompositorManager2(); const Ogre::String workspaceName = "default scene workspace"; const Ogre::IdString workspaceNameHash = workspaceName; compMan->createBasicWorkspaceDef(workspaceName, m_ogreBackground); compMan->addWorkspace(m_ogreSceneMgr, m_ogreWindow, m_ogreCamera, workspaceNameHash, true); } #endif void QTOgreWindow::render() { /* How we tied in the render function for OGre3D with QWindow's render function. This is what gets call repeatedly. Note that we don't call this function directly; rather we use the renderNow() function to call this method as we don't want to render the Ogre3D scene unless everything is set up first. That is what renderNow() does. Theoretically you can have one function that does this check but from my experience it seems better to keep things separate and keep the render function as simple as possible. */ // Ogre::WindowEventUtilities::messagePump(); m_ogreRoot->renderOneFrame(); } void QTOgreWindow::renderLater() { /* This function forces QWindow to keep rendering. Omitting this causes the renderNow() function to only get called when the window is resized, moved, etc. as opposed to all of the time; which is generally what we need. */ if (!m_update_pending) { m_update_pending = true; QApplication::postEvent(this, new QEvent(QEvent::UpdateRequest)); } } bool QTOgreWindow::event(QEvent *event) { /* QWindow's "message pump". The base method that handles all QWindow events. As you will see there are other methods that actually process the keyboard/other events of Qt and the underlying OS. Note that we call the renderNow() function which checks to see if everything is initialized, etc. before calling the render() function. */ switch (event->type()) { case QEvent::UpdateRequest: m_update_pending = false; renderNow(); return true; default: return QWindow::event(event); } } /* Called after the QWindow is reopened or when the QWindow is first opened. */ void QTOgreWindow::exposeEvent(QExposeEvent *event) { Q_UNUSED(event); if (isExposed()) renderNow(); } /* The renderNow() function calls the initialize() function when needed and if the QWindow is already initialized and prepped calls the render() method. */ void QTOgreWindow::renderNow() { if (!isExposed()) return; if (m_ogreRoot == NULL) { initialize(); } render(); if (m_animating) renderLater(); } /* Our event filter; handles the resizing of the QWindow. When the size of the QWindow changes note the call to the Ogre3D window and camera. This keeps the Ogre3D scene looking correct. */ bool QTOgreWindow::eventFilter(QObject *target, QEvent *event) { if (target == this) { if (event->type() == QEvent::Resize) { if (isExposed() && m_ogreWindow != NULL) { m_ogreWindow->resize(this->width(), this->height()); } } } return false; } /* How we handle keyboard and mouse events. */ void QTOgreWindow::keyPressEvent(QKeyEvent * ev) { if(m_cameraMan) m_cameraMan->injectKeyDown(*ev); } void QTOgreWindow::keyReleaseEvent(QKeyEvent * ev) { if(m_cameraMan) m_cameraMan->injectKeyUp(*ev); } void QTOgreWindow::mouseMoveEvent( QMouseEvent* e ) { static int lastX = e->x(); static int lastY = e->y(); int relX = e->x() - lastX; int relY = e->y() - lastY; lastX = e->x(); lastY = e->y(); if(m_cameraMan && (e->buttons() & Qt::LeftButton)) m_cameraMan->injectMouseMove(relX, relY); } void QTOgreWindow::wheelEvent(QWheelEvent *e) { if(m_cameraMan) m_cameraMan->injectWheelMove(*e); } void QTOgreWindow::mousePressEvent( QMouseEvent* e ) { if(m_cameraMan) m_cameraMan->injectMouseDown(*e); } void QTOgreWindow::mouseReleaseEvent( QMouseEvent* e ) { if(m_cameraMan) m_cameraMan->injectMouseUp(*e); QPoint pos = e->pos(); Ogre::Ray mouseRay = m_ogreCamera->getCameraToViewportRay( (Ogre::Real)pos.x() / m_ogreWindow->getWidth(), (Ogre::Real)pos.y() / m_ogreWindow->getHeight()); Ogre::RaySceneQuery* pSceneQuery = m_ogreSceneMgr->createRayQuery(mouseRay); pSceneQuery->setSortByDistance(true); Ogre::RaySceneQueryResult vResult = pSceneQuery->execute(); for (size_t ui = 0; ui < vResult.size(); ui++) { if (vResult[ui].movable) { if (vResult[ui].movable->getMovableType().compare("Entity") == 0) { emit entitySelected((Ogre::Entity*)vResult[ui].movable); } } } m_ogreSceneMgr->destroyQuery(pSceneQuery); } /* Function to keep track of when we should and shouldn't redraw the window; we wouldn't want to do rendering when the QWindow is minimized. This takes care of those scenarios. */ void QTOgreWindow::setAnimating(bool animating) { m_animating = animating; if (animating) renderLater(); } bool QTOgreWindow::frameRenderingQueued(const Ogre::FrameEvent& evt) { m_cameraMan->frameRenderingQueued(evt); return true; } void QTOgreWindow::log(Ogre::String msg) { if(Ogre::LogManager::getSingletonPtr() != NULL) Ogre::LogManager::getSingletonPtr()->logMessage(msg); } void QTOgreWindow::log(QString msg) { log(Ogre::String(msg.toStdString().c_str())); }

    widget.cpp

    #include "widget.h" Widget::Widget(QWidget *parent) : QWidget(parent) { QTOgreWindow * ogreWindow = new QTOgreWindow (); ogreWindow->show (); } Widget::~Widget() { }

    plugin.cfg

    # Defines plugins to load # Define plugin folder PluginFolder=/usr/local/lib/OGRE # Define plugins # Plugin=RenderSystem_Direct3D9 # Plugin=RenderSystem_Direct3D11 Plugin=RenderSystem_GL Plugin=RenderSystem_GL3Plus Plugin=RenderSystem_GLES2 # Plugin=RenderSystem_Metal # Plugin=RenderSystem_Tiny Plugin=Plugin_ParticleFX Plugin=Plugin_BSPSceneManager # Plugin=Plugin_CgProgramManager Plugin=Codec_EXR Plugin=Codec_STBI # Plugin=Codec_FreeImage Plugin=Plugin_PCZSceneManager Plugin=Plugin_OctreeZone Plugin=Plugin_OctreeSceneManager Plugin=Plugin_DotScene # Plugin=Codec_Assimp

    Screenshot_20211208_120343.png

    the first part of the answer at the top (failed to fit into one message)

  • 0 Votes
    2 Posts
    525 Views
    B

    If I understood correctly, you want to draw a red line.
    The purpose of Path is to position elements through a path. Think of a row or a column that's not straight. You can understand better if you run the first example from this tutorial.

    To draw paths you need Shape.

    import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Shapes 1.12 Window { width: 640 height: 480 visible: true title: qsTr("Редактор персонажей") Shape { ShapePath { strokeColor: "red"; // it works :) startX: 0; startY: 100 PathLine { x: 640; y: 480 } } } }
  • 0 Votes
    10 Posts
    532 Views
    Christian EhrlicherC

    And this example still has the errors? Then simplify it (and fix the memleaks - a new[] needs a delete[] and paintGL() is not called only once so your vectors grow indefinitly) until we can really try it out. E.g. loading an object file is not needed - drawing a simple rectangle to reproduce the issue is enough.

  • 0 Votes
    18 Posts
    1k Views
    JonBJ

    @vicky_mac said in close(int fd) not recognized in QT both fcntl.h and unistd.h are included:

    I am getting the same error even after MainWindow::close(fd)

    Both @KroMignon and I said from the start and multiple times to try ::close(fd);. Same with ::open(). How much clearer than that can one be?

    If you want to be "safe", every single C (not C++) function you want to use should be ::function().

  • 0 Votes
    5 Posts
    664 Views
    SGaistS

    Hi and welcome to devnet,

    QtGStreamer is unmaintained.

    Depending on what you want to do, you can use the custom pipeline option of QMediaPlayer::setMedia.

  • 0 Votes
    2 Posts
    1k Views
    Pablo J. RoginaP

    @alizadeh91 have you check the documentation about CircularGaugeStyle?

    When defining your own needle component, the only properties that the style requires you to set are the implicitWidth and implicitHeight.

    which looks like you're not setting.

    Also this document refers to styling the needle and those mentioned properties.

  • 0 Votes
    2 Posts
    609 Views
    M

    @magicstar I have the same problem. Have you find a solution ?

  • 0 Votes
    3 Posts
    761 Views
    banditoB

    That was to whole error. As for code I have too much to post.

    Anyhow I fixed it by creating a new header file, copying the contents from the original header file into the new one, deleting the original and renaming the new header file to the name of the original one.

  • 0 Votes
    2 Posts
    439 Views
    KroMignonK

    I found a solution for my problem.
    I had to set renderType=Text.QtRendering to solve the issue.
    With Qt 5.4.2, I had to set renderType=Text.NativeRendering

    Very strange to me, but works ;)

    Regards

    Fabrice

  • 0 Votes
    3 Posts
    649 Views
    A

    @primem0ver Yes I'm using Qt5.11.2.

  • 0 Votes
    13 Posts
    4k Views
    kshegunovK

    @Christian-Ehrlicher said in SQLite3 Errors: Parameter count mismatch and Unable to fetch row:

    This overload is really confusion and I wonder if it should not be marked as deprecated. There were already some bugreports about this because the usage was unexpected to the users so they did an exec afterwards and screwed up the query with it.

    I appreciate your discreetness, but I don't try to hide my stupidity. ;)

  • 0 Votes
    3 Posts
    1k Views
    Michael RozshkoM

    You are right! It is my error, rebuild all project with full delete old directory and all work fine. Thanks for fast and good answer!