Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Drawing problem, some area does not draw well on Windows machine.
Forum Updated to NodeBB v4.3 + New Features

Drawing problem, some area does not draw well on Windows machine.

Scheduled Pinned Locked Moved QML and Qt Quick
14 Posts 2 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haiying
    wrote on last edited by
    #5

    Thanks for your reply.
    Do you mean to use QtQuick2ApplicationViewer instead of QQuickView in main.cpp? Could you share your main.cpp code?
    And I'm using qt 5.2.
    Thanks and regards.

    1 Reply Last reply
    0
    • O Offline
      O Offline
      onek24
      wrote on last edited by
      #6

      No, i was using QtQuick2ApplicaionViewer. I'll provide you the code tomorrow.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        haiying
        wrote on last edited by
        #7

        Thanks for your reply!
        I hope to try it!

        1 Reply Last reply
        0
        • O Offline
          O Offline
          onek24
          wrote on last edited by
          #8

          I was using your qml-code so i won't post it again but here are the other files:

          • main.qml (Your unit.qml)
          • slot1.qml
          • main.cpp @#include <QtGui/QGuiApplication>
            #include "qtquick2applicationviewer.h"

          int main(int argc, char *argv[])
          {
          QGuiApplication app(argc, argv);

          QtQuick2ApplicationViewer viewer;
          viewer.setMainQmlFile&#40;QStringLiteral("qml/forumqmltest/main.qml"&#41;&#41;;
          viewer.showExpanded(&#41;;
          
          return app.exec(&#41;;
          

          }@

          • qtquick2applicationviewer.h (Default, unchanged) @#ifndef QTQUICK2APPLICATIONVIEWER_H
            #define QTQUICK2APPLICATIONVIEWER_H

          #include <QtQuick/QQuickView>

          class QtQuick2ApplicationViewer : public QQuickView
          {
          Q_OBJECT

          public:
          explicit QtQuick2ApplicationViewer(QWindow *parent = 0);
          virtual ~QtQuick2ApplicationViewer();

          void setMainQmlFile&#40;const QString &file&#41;;
          void addImportPath(const QString &path&#41;;
          
          void showExpanded(&#41;;
          

          private:
          class QtQuick2ApplicationViewerPrivate *d;
          };

          #endif // QTQUICK2APPLICATIONVIEWER_H@

          • qtquick2applicationviewer.cpp (Default, unchanged) @#include "qtquick2applicationviewer.h"

          #include <QtCore/QCoreApplication>
          #include <QtCore/QDir>
          #include <QtQml/QQmlEngine>

          class QtQuick2ApplicationViewerPrivate
          {
          QString mainQmlFile;
          friend class QtQuick2ApplicationViewer;
          static QString adjustPath(const QString &path);
          };

          QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path)
          {
          #if defined(Q_OS_MAC)
          if (!QDir::isAbsolutePath(path))
          return QString::fromLatin1("%1/../Resources/%2")
          .arg(QCoreApplication::applicationDirPath(), path);
          #elif defined(Q_OS_BLACKBERRY)
          if (!QDir::isAbsolutePath(path))
          return QString::fromLatin1("app/native/%1").arg(path);
          #elif !defined(Q_OS_ANDROID)
          QString pathInInstallDir =
          QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
          if (QFileInfo(pathInInstallDir).exists())
          return pathInInstallDir;
          pathInInstallDir =
          QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path);
          if (QFileInfo(pathInInstallDir).exists())
          return pathInInstallDir;
          #endif
          return path;
          }

          QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent)
          : QQuickView(parent)
          , d(new QtQuick2ApplicationViewerPrivate())
          {
          connect(engine(), SIGNAL(quit()), SLOT(close()));
          setResizeMode(QQuickView::SizeRootObjectToView);
          }

          QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer()
          {
          delete d;
          }

          void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file)
          {
          d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file);
          #ifdef Q_OS_ANDROID
          setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile));
          #else
          setSource(QUrl::fromLocalFile(d->mainQmlFile));
          #endif
          }

          void QtQuick2ApplicationViewer::addImportPath(const QString &path)
          {
          engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path));
          }

          void QtQuick2ApplicationViewer::showExpanded()
          {
          #if defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX)
          showFullScreen();
          #else
          show();
          #endif
          }@

          • qtquick2applicationviewer.pri (Default, unchanged, too big to post)
          • forumqmltest.pro @# Add more folders to ship with the application, here
            folder_01.source = qml/forumqmltest
            folder_01.target = qml
            DEPLOYMENTFOLDERS = folder_01

          Additional import path used to resolve QML modules in Creator's code model

          QML_IMPORT_PATH =

          If your application uses the Qt Mobility libraries, uncomment the following

          lines and add the respective components to the MOBILITY variable.

          CONFIG += mobility

          MOBILITY +=

          The .cpp file which was generated for your project. Feel free to hack it.

          SOURCES += main.cpp

          Installation path

          target.path =

          Please do not modify the following two lines. Required for deployment.

          include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
          qtcAddDeployment()

          OTHER_FILES +=
          qml/forumqmltest/slot1.qml@

          The qtquick2applicationviewer is automatically generated if you create a new QtQuick2 project. I'll try the same with QtQuickView now.

          1 Reply Last reply
          0
          • O Offline
            O Offline
            onek24
            wrote on last edited by
            #9

            Alright, i have tested it with QtQuickView and it works fine, too. I'll provide you the code:

            • slot1.qml
            • unit.qml
            • main.cpp (Default, unchanged) @#include "mainwindow.h"
              #include <QApplication>

            int main(int argc, char *argv[])
            {
            QApplication a(argc, argv);
            MainWindow w;
            w.show();

            return a.exec&#40;&#41;;
            

            }@

            • mainwindow.h (Default, unchanged) @#ifndef MAINWINDOW_H
              #define MAINWINDOW_H

            #include <QMainWindow>

            namespace Ui {
            class MainWindow;
            }

            class MainWindow : public QMainWindow
            {
            Q_OBJECT

            public:
                explicit MainWindow(QWidget *parent = 0&#41;;
                ~MainWindow(&#41;;
            
            private:
                Ui::MainWindow *ui;
            

            };

            #endif // MAINWINDOW_H@

            • mainwindow.cpp @#include "mainwindow.h"
              #include "ui_mainwindow.h"
              #include <QQuickView>

            MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
            {
            ui->setupUi(this);
            this->setGeometry(200, 200, 600, 400);
            QQuickView *view = new QQuickView();
            view->setSource(QUrl("qrc:/qml/unit.qml"));
            QWidget *container = QWidget::createWindowContainer(view, this);
            container->setGeometry(0, 0, 600, 400);
            container->show();
            }

            MainWindow::~MainWindow()
            {
            delete ui;
            }@

            • mainwindow.ui @<?xml version="1.0" encoding="UTF-8"?>
              <ui version="4.0">
              <class>MainWindow</class>
              <widget class="QMainWindow" name="MainWindow">
              <property name="geometry">
              <rect>
              <x>0</x>
              <y>0</y>
              <width>400</width>
              <height>300</height>
              </rect>
              </property>
              <property name="windowTitle">
              <string>MainWindow</string>
              </property>
              <widget class="QWidget" name="centralWidget"/>
              <widget class="QMenuBar" name="menuBar">
              <property name="geometry">
              <rect>
              <x>0</x>
              <y>0</y>
              <width>400</width>
              <height>21</height>
              </rect>
              </property>
              </widget>
              </widget>
              <layoutdefault spacing="6" margin="11"/>
              <resources/>
              <connections/>
              </ui>@
            • rsc.qrc @<RCC>
              <qresource prefix="/qml">
              <file>slot1.qml</file>
              <file>unit.qml</file>
              </qresource>
              </RCC>@
            • qtquickviewtest.pro @QT += core gui quick

            greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

            TARGET = qtquickviewtest
            TEMPLATE = app

            SOURCES += main.cpp
            mainwindow.cpp

            HEADERS += mainwindow.h

            FORMS += mainwindow.ui

            OTHER_FILES +=
            unit.qml
            slot1.qml

            RESOURCES +=
            rsc.qrc@

            I would guess that it's a bug. Which QT version are you using?

            1 Reply Last reply
            0
            • H Offline
              H Offline
              haiying
              wrote on last edited by
              #10

              Thanks very much for your sharing the code. I will try it later.
              I also guess it is a bug.
              I'm using Qt 5.2.0 MSVC2012 32bit.

              Thanks again and regards!!!

              1 Reply Last reply
              0
              • O Offline
                O Offline
                onek24
                wrote on last edited by
                #11

                Yes, try it out and tell me if it worked. It seems to be a bug if the same code doesn't work in Qt 5.2.0. There isn't such a big difference between 5.2.0 and 5.2.1. Also have you tried your project with a QQuickView, yet?

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  haiying
                  wrote on last edited by
                  #12

                  Hello, I tried your code, but still had the same problem.
                  Please see the below URL, the second picture is the result of your code.
                  http://ameblo.jp/jianghaiying2002/entry-11768624153.html

                  Yes, I have tried my code, the first picture is the result of my code, the following code.

                  test.pro
                  @QT += qml quick declarative webkit

                  SOURCES += main.cpp

                  RESOURCES += test.qrc

                  DESTPATH = /home/qt3/qttest/test
                  target.path = $$DESTPATH

                  qml.files = *.qml
                  qml.path = $$DESTPATH

                  INSTALLS += target qml

                  OTHER_FILES +=
                  unit.qml
                  slot1.qml @

                  main.cpp
                  @#include <QtQuick/QQuickView>
                  #include <QGuiApplication>

                  int main(int argc, char *argv[])
                  {
                  QGuiApplication app(argc, argv);

                  QQuickView view;
                  view.setResizeMode(QQuickView::SizeRootObjectToView);
                  view.setSource(QUrl("qrc:///unit.qml"));
                  view.show();
                  return app.exec();
                  

                  }@

                  test.qrc
                  @<RCC>
                  <qresource prefix="/">
                  <file>unit.qml</file>
                  <file>slot1.qml</file>
                  </qresource>
                  </RCC>@

                  and unit.qml, slot1.qml

                  I will try it on Qt5.2.1 later.
                  Thanks again.

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    onek24
                    wrote on last edited by
                    #13

                    Hello, it looks like a bug to me. Would you mind posting your issue here:
                    "Bugreports":https://bugreports.qt-project.org/secure/Dashboard.jspa

                    Also could you please tell me if and which graphics card you're using?

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      haiying
                      wrote on last edited by
                      #14

                      Hello, the graphics card in my windows machine is Mobile Intel 4 Series Express Chipset Family.
                      And I will try to issue the bug later.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved