qt5

Add QMultiSampleAntiAliasing to a QForwardRenderer

蹲街弑〆低调 提交于 2020-01-05 07:08:01
问题 I'm trying to enable Multisampling in qt3d. The Qt3DExtras::Qt3DWindow already does the following during initialisation: format.setDepthBufferSize(24); format.setSamples(4); format.setStencilBufferSize(8); setFormat(format); QSurfaceFormat::setDefaultFormat(format); which is a good start. So according to this post, the only OpenGL call necessary to enable Multisampling would be glEnable(GL_MULTISAMPLE); And indeed, the documentation of documentation of QMultiSampleAntiAliasing states: Note:

How to draw a QPixmap at pos(0, 0) including margin/padding sizes

Deadly 提交于 2020-01-05 06:50:50
问题 Inside SidebarButton.paintEvent(), I want to draw a pixmap at position x=0, y=0. When margin:0px is set, this works fine. But if I increase for example margin-top to 30px, drawPixmap(0, 0, ...) paints inside the margin. I've expected that if I set a top margin, drawPixmap(0, 0, ...) starts at (0, 30). So my question is: how can I draw at the correct position? A simple solution would be drawPixmap(0, getTopMargin() + getTopPadding(), ...) But I can't find any function which gives me the css

Get list of languages in Qt5

陌路散爱 提交于 2020-01-04 13:43:32
问题 I want to get the list of ISO 639 languages, from QLocale . I can use this code to get all combinations of language/country. QList<QLocale> allLocales = QLocale::matchingLocales( QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); This is exactly what I need. I assume I can filter out the list manually, but does a better alternative exist? 回答1: You can do either that or do something not nearly as nice (see end of this post) and filter duplicate languages from the list manually, e

[Qt5] 使用Qt设计器绘制主窗口

∥☆過路亽.° 提交于 2020-01-04 09:51:51
实践代码: git clone https://github.com/dilexliu/learn_qt5.git Step1: Qt设计器绘制窗口 保存会得到一个文件: mainwindow.ui 另外还需要把mainwindow.ui 的代码保存出来,操作:在Qt设计器中的菜单栏【窗体】->【查看代码】,把其中的代码保存为 ui_mainwindow.h Step2: 手动添加代码 mainwindow.h #pragma once #include "ui_mainwindow.h" class CMainWindow : public QMainWindow, public Ui_MainWindow { Q_OBJECT public: CMainWindow(QWidget* = 0); }; mainwindow.cpp #include <QtGui> #include "mainwindow.h" CMainWindow::CMainWindow(QWidget* parent) : QMainWindow(parent) { this->setupUi(this); this->show(); } main.cpp #include <QtGui> #include "mainwindow.h" CMainWindow::CMainWindow(QWidget*

CMake编译Qt程序+UI+Resources

落花浮王杯 提交于 2020-01-04 09:51:00
今天给大家讲解一下Cmake如何编译Qt程序。 这里说的Qt程序不只是用QtCreator写出来的程序,当然也可以是文本编辑器…。这里说的Qt程序是指,QCoreApplication,QApplication( QMainWindow,QWidget,QDialogue)类型的程序。 CMake是一个跨平台的非常通用的于编译器,用cmake命令可以生产出makefile,在利用make编译程序,这里不多说了,大家比较了解。当然首先得有CMakeLists.txt,我们手动建立一个.txt文件或者利用QtCreator新建一个CMake工程都可以,下面就来看一下,如何写这个CMakeLists,好让Qt程序能编译通过。 一个CMakeLists.txt的完整示例与分块讲解 如何添加Qt库 如何添加 .ui文件与资源文件.qrc 1. 一个CMakeLists.txt的完整示例与分块讲解 project(project_test) cmake_minimum_required(VERSION 2.8) #set(CMAKE_BUILD_TYPE "Release") #using CMAKE_BUILD_TYPE to set the cmake method [Debug | Release] # CMAKE_CXX_FLAGS CMake C++ set(CMAKE_CXX

Qt TextField is not invoking the keyboard when launched on Android device

时间秒杀一切 提交于 2020-01-04 08:19:13
问题 I have simple QML app, that shows only one TextField : Rectangle { color: "#00000000" TextField { anchors.centerIn: parent } } I thought, that Android keyboard will be shown automatically, when I touch on TextField , but it's not happening. I tried to use focus , Qt.inputMethod.show() , forceActiveFocus() inside Component.onCompleted of TextField and many other methods, but keyboard not shown anyway. Tried to use app on other devices and Android 4.1-4.4 versions, but result always the same ))

QNetworkReply: Network access is disabled in QWebView

喜夏-厌秋 提交于 2020-01-04 07:11:22
问题 I cannot load website into my QWebView, QNetworkReply is returning me the error: Network Access is disabled . Loading files from local works. I am using Qt5. Does anyone know why is connection disabled and how this line affects this situation: QNetworkProxyFactory::setUseSystemConfiguration(false); My eth0 connection works properly, and I am able to ping any website. 回答1: From the Qt doc : calling setUseSystemConfiguration() overrides any application proxy or proxy factory that was previously

Set Loader item property

孤街浪徒 提交于 2020-01-04 02:04:09
问题 In the context of a file manager, I have a TableView component saved in the file dirview.qml , which displays the content of some directory using FolderListModel : import QtQuick 2.4 import QtQuick.Controls 1.4 import Qt.labs.folderlistmodel 2.1 TableView { id: tableView property string folder_url: "file:///tmp" anchors.fill: parent TableViewColumn { role: "fileName" title: qsTr("Name") width: tableView.width * 0.7 } TableViewColumn { role: "fileURL" title: qsTr("Size") width: tableView.width

With Qt, what are good ways to break up a large source file containing GUI logic?

我与影子孤独终老i 提交于 2020-01-03 19:10:37
问题 I'm working on a project in C++ utilizing Qt 5, and it has a complex window with large number of UI elements. This window was designed using Qt Designer and is loaded from a UI file. The pattern that I've found typical of Qt is to write all of the logic for a window's UI in its main, encompassing class; i.e. the "Single Inheritance Approach" from their documentation. For example, you have a class named QMyWindow and a corresponding qmywindow.ui file defining the layout, with QMyWindow

With Qt, what are good ways to break up a large source file containing GUI logic?

我是研究僧i 提交于 2020-01-03 19:08:03
问题 I'm working on a project in C++ utilizing Qt 5, and it has a complex window with large number of UI elements. This window was designed using Qt Designer and is loaded from a UI file. The pattern that I've found typical of Qt is to write all of the logic for a window's UI in its main, encompassing class; i.e. the "Single Inheritance Approach" from their documentation. For example, you have a class named QMyWindow and a corresponding qmywindow.ui file defining the layout, with QMyWindow