qt5

How to display window form fullscreen on second monitor in Qt?

你。 提交于 2019-12-23 20:25:32
问题 I m using Qt5 on linux, I want to display window form fullscreen on second screen (dual monitor)? I tried this code but it doesnt work. Is there any other way? QRect screenres = QApplication::desktop()->screenGeometry(1/*screenNumber*/); Widget *secondDisplay = new Widget(); // Use your QWidget secondDisplay->move(QPoint(screenres.x(), screenres.y())); secondDisplay->resize(screenres.width(), screenres.height()); 回答1: You can use QScreen . QScreen *screen = QGuiApplication::screens()[1]; //

Qt 5.0.1: Application will not execute outside of Qt creator

断了今生、忘了曾经 提交于 2019-12-23 20:13:29
问题 I am trying to run the program TransitTalker.exe, which is my compiled code from qt, as shown in this picture: https://www.dropbox.com/s/ypgklrm4uschri5/filecontents.png (Note that I do not have sufficient reputation to post images, which the reason why I provided a link to the image) My problem: My program does not execute outside of qt creator. I get the following message attempting to run TransitTalker.exe: "This application has requested the Runtime to terminate it in an unusual way.

Is the QTcpSocket (or QSslSocket) which underlies a QWebSocket — destroyed by itself when a socket error happens?

混江龙づ霸主 提交于 2019-12-23 18:17:40
问题 When a QTcpSocket (or QSslSocket ) is upgraded to a QWebSocket , the former has to be stored for the future purpose, as it requires to be ... moved to the same thread wherever QWebSocket is being moveToThread() deleteLater() whenever QWebSocket is being destroyed Failing to do 1. results in undefined behaviour and most likely a crash. While failing to do 2. results in a memory leak, which is more prominent if you are having a QWebSocketServer (QWebSocketServer - not releasing memory). I

Qt: Could not read from input device: No such device

情到浓时终转凉″ 提交于 2019-12-23 17:31:59
问题 I have a Qt application that's been built to run on Embedded Linux platform (i.Mx.6). My application should support both touch screen as primary input device and an optional USB keyboard if connected. So for now, I have configured my application to be launched as mentioned below: my-qt-app -plugin tslib:/dev/input/event0 -plugin evdevkeyboard:/dev/input/event1 My application is able to detect the touchscreen and keyboard properly, BUT, I am noticing a problem if I unplug the keyboard while my

QWidget for showing text with small pictures (icons/emoticons)

折月煮酒 提交于 2019-12-23 17:08:39
问题 Does such widget exist? I can write my own widget based on QLabel s and layout similar to http://qt-project.org/doc/qt-5/qtwidgets-layouts-flowlayout-example.html, but then I can't select all text and copy (because this is just a set of labels). 回答1: A QLabel's text property can have rich text in it, and the img tag is supported in rich text in Qt. For example, QLabel myLabel("<img src=\":/foo.png\"> Hello, World!"); 回答2: You can use a QTextEdit in which when you enter some specific text, it

Best Practice For Qt Includes And Precompiled Headers?

不羁的心 提交于 2019-12-23 12:02:51
问题 What's the current "best practice" regarding the inclusion of Qt header files when using a modern and recent C++ compiler (e.g. MSVC2015) with precompiled headers activated? Example: #include <QStringList> #include <QTreeWidget> #include <QListWidget> vs. #include <QtCore> #include <QtGui> What convention should I choose for a new project? What are the benefits/drawbacks of either? What is more common for new projects? 回答1: As far as I know, there is no specific limitation/recommendation

How to change style in Qt5qt

时光毁灭记忆、已成空白 提交于 2019-12-23 10:21:08
问题 I am writing a Qt5 application by using PyQt. I would like to understand how to change the style of the entire application. The old Qt4 calls like app = QApplication(sys.argv) app.setStyle(QStyleFactory.create('Cleanlooks')) as suggested here does nothing. Are they deprecated? https://blog.qt.io/blog/2012/10/30/cleaning-up-styles-in-qt5-and-adding-fusion/ Thank you! 回答1: may be Cleanlooks is no longer available on your system. By QStyleFactory.keys() you can ask the available styles on your

Combine toolbar and title bar in Qt

拟墨画扇 提交于 2019-12-23 10:09:48
问题 How can the toolbar be implemented in the top bar, like, for example, Tiled has it done? Normally, the toolbar looks like the follows: Example code how it is currently: class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = nullptr) { auto *tbar = new QToolBar(); tbar->addWidget(new QPushButton("Push Me")); this->addToolBar(tbar); } }; 回答1: If you are still using Qt 4.x, you can just use the setUnifiedTitleAndToolBarOnMac(bool set) function that is

Corrupted resource .cpp file when using QT5_ADD_RESOURCES and multithread compiling with CMake

一曲冷凌霜 提交于 2019-12-23 09:50:04
问题 The 5.0 release of Qt has brought a set of easier commands to build Qt projects using CMake. See http://qt-project.org/doc/qt-5/cmake-manual.html. Resources for a project need to be included using the command QT5_ADD_RESOURCES . If my resource file is named for instance Icon32.qrc, the QT5_ADD_RESOURCES(RESOURCES Icon32.qrc) command will automatically convert it into a qrc_Icon32.cpp file and define a ${RESOURCES} variable that I will then be able to include into the proper targets. Doing

Flow layout with centered content

蹲街弑〆低调 提交于 2019-12-23 09:25:39
问题 I have a row with items which should stack when the window width gets too small for displaying all items in a row, as shown in the following sketch: The Flow component stacks the items but they are not centered but aligned on the left or right side: Flow { Item {} Item {} Item {} Item {} Item {} } Is there a built-in way in QML to make the flow centered? 回答1: Well there is no built-in way but I found a workaround to do it. The idea is simple, since Flow is already an Item it has anchors