qtwidgets

What is parent for in Qt?

北战南征 提交于 2019-12-03 10:35:52
Almost every QtWidgets class can have parent. And usually it's optional to set parent at object initialization. For example,If I create a class that inherits QWidget class, I will do the following on the constructor: Widget::Widget(QWidget* parent): QWidget(parent) { hbox = new QHBoxLayout(this); yes_button = new QPushButton("&Yes"); no_button = new QPushButton("&No", this); cancel_button = new QPushButton("&Cancel", hbox); } I can set or not set parent. I can set cancel_button to be a child of hbox . I can too set cancel_button to be a child of yes_button , but I think it's a bad thing to do.

QtWidgets.QFileDialog.getOpenFileName returns a Tuple

南笙酒味 提交于 2019-12-01 00:40:00
问题 I've recently updated to the new version of Qt5 for Python. In doing so, I've been having to alter my code in accordance to some of the notable changes that have occurred. I wanted to get some insight into this line of code that I've created. It feels like a dirty way of solving the problem of getting a string instead of a tuple from the function. (Note the [0] at the end of the line) filename = QtWidgets.QFileDialog.getOpenFileName(None, "Open " + key + " Data File", '.', "(*.csv)")[0] I

qt-updating ui by thread

試著忘記壹切 提交于 2019-12-01 00:02:59
hi I have a problem with updating ui by a thread. code works correctly but the problem is when I want to move my window as you know in that moment ui thread will stop updating. and my thread sends values to stopped thread that causes error. I don't know how to fix this. here is my thread code header: #ifndef READERTHREAD_H #define READERTHREAD_H #include <QtSerialPort/QSerialPort> #include <QtSerialPort/QSerialPortInfo> #include <QThread> class readerThread : public QThread { Q_OBJECT public: explicit readerThread(QObject *parent = 0); void run(); bool stop = false; QByteArray port_input;

Implementing resize handles on QRubberband? Is QSizeGrip relevant?

核能气质少年 提交于 2019-11-30 05:08:26
I'd like to make my QRubberband instance user resizeable. I've seen this question here but there isn't a solution. The use case is that the user can drag out a selection marquee over a photo and then make fine adjustments by dragging on the QRubberband margins to change geometry, or reposition existing geometry by dragging the selection. I have the repositioning implemented but I am wondering about resize handles for changing the geometry of the QRubberband. Is it possible to use QSizeGrip here? Barring that, is there a standard way of checking for mouse-within-margin type events within Qt or

Implementing resize handles on QRubberband? Is QSizeGrip relevant?

此生再无相见时 提交于 2019-11-29 02:54:22
问题 I'd like to make my QRubberband instance user resizeable. I've seen this question here but there isn't a solution. The use case is that the user can drag out a selection marquee over a photo and then make fine adjustments by dragging on the QRubberband margins to change geometry, or reposition existing geometry by dragging the selection. I have the repositioning implemented but I am wondering about resize handles for changing the geometry of the QRubberband. Is it possible to use QSizeGrip

cmake does not find qt 5.1.1

℡╲_俬逩灬. 提交于 2019-11-28 23:37:15
I just installed the Qt 5.1.1 for Windows 32-bit (MinGW 4.8, OpenGL) and tried to add it to my cmake. But CMake just does not want to find it and i dont know why. What am i missing? Do i need to set an environment variable or something? Here is my cmake : cmake_minimum_required( VERSION 2.8.11 ) PROJECT(Blemmer) # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) # Detect and add SFML set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" ${CMAKE_MODULE_PATH}) set( CMAKE_RUNTIME

Hide label text for Qt tabs without setting text to empty string

随声附和 提交于 2019-11-28 13:51:26
I need a QTabWidget with icons only: How can I hide the label text of a tab in Qt? I cannot set the text to an empty string ( "" ), as I am using docked widgets ( QDockWidget ) and the label text is set automatically (and I need it if the widget is floating). But in tabbed mode I just want to display the icons (of the tabs). Possible approaches: Font size to 0? I need to create my own bar class and override the paint event as here Anything easier / cleaner? --- Edit --- Ok, the "set window title to empty string, and reset it the original text" approach works. I am using the topLevelChanged

cmake does not find qt 5.1.1

守給你的承諾、 提交于 2019-11-27 15:04:26
问题 I just installed the Qt 5.1.1 for Windows 32-bit (MinGW 4.8, OpenGL) and tried to add it to my cmake. But CMake just does not want to find it and i dont know why. What am i missing? Do i need to set an environment variable or something? Here is my cmake : cmake_minimum_required( VERSION 2.8.11 ) PROJECT(Blemmer) # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) # Detect and add SFML

What's the difference between QMainWindow, QWidget and QDialog?

自闭症网瘾萝莉.ら 提交于 2019-11-27 09:06:56
问题 What's the difference between QMainWindow, QWidget and QDialog? 回答1: A QWidget is the base class for all drawable classes in Qt. Any QWidget -based class can be shown as a window by showing it when it has no parent. A QDialog is based on QWidget , but designed to be shown as a window. It will always appear in a window, and has functions to make it work well with common buttons on dialogs (accept, reject, etc.). QMainWindow is designed around common needs for a main window to have. It has

Hide label text for Qt tabs without setting text to empty string

二次信任 提交于 2019-11-27 07:58:13
问题 I need a QTabWidget with icons only: How can I hide the label text of a tab in Qt? I cannot set the text to an empty string ( "" ), as I am using docked widgets ( QDockWidget ) and the label text is set automatically (and I need it if the widget is floating). But in tabbed mode I just want to display the icons (of the tabs). Possible approaches: Font size to 0? I need to create my own bar class and override the paint event as here Anything easier / cleaner? --- Edit --- Ok, the "set window