qt4

Qt Tray Icon Drag and Drop

蓝咒 提交于 2021-02-07 07:15:50
问题 Does anyone know if it is possible to use drag and drop with a tray icon using Qt? 回答1: I've been doing some research and here is what I have come up with: A QSystemTrayIcon cannot explicitly handle a drag/drop event. However there is a workaround based on the Spifftastic tray icon location method. You create a uniquely colored icon and place it as the icon for a brief moment and take a screenshot of it. Given that you know the color sequence for the icon, you can search through the

Prevent QML Property Bindings when QML object isn't visible?

谁说胖子不能爱 提交于 2021-02-07 06:53:15
问题 I'm working on a QML application that has a lot of property bindings: hundreds of objects are tracked and displayed in different forms like Qt3D/QCanvas. When I'm on a separate page of the application those property bindings for x/y locations and relative sizes are still happening. How can I stop them? I know I could bind the properties based on whether they're visual or not but that is a lot of unnecessary code: x: visible ? tracking.location(index).x : 0 I would have to wrap a ton of

How to add submenu in Qt

空扰寡人 提交于 2021-02-04 14:30:14
问题 How do I add a submenu from the menu below? I need a submenu to open, say, after clicking "A->Setup" I want a submenu to be opened to the side of the main menu. void MyMenu::cppSlot() { QMenu *xmenu = new QMenu; xmenu->addMenu("A -> Setup"); xmenu->addMenu("B -> Setup"); xmenu->addMenu("C -> Setup"); xmenu->addMenu("D -> Setup"); xmenu->addMenu("E -> Setup"); //Change font and width xmenu->setFont(QFont ("Courier", 10)); xmenu->setFixedWidth(250); //Colour setting xmenu->setAutoFillBackground

How to link a QPushButton to a tab of QTabWidget?

假如想象 提交于 2021-01-29 04:43:32
问题 I am using Qt to do a GUI program, so my problem is, I have made a homepage in my GUI program and I have some 4 tabs tab1,tab2,tab3,tab4 and I have made QPushbutton over at homepage. So can anyone tell me how can I link QPushButton to tab3 of QTabWidget so that when I click the button it should take me to tab 3. Thank you 回答1: First create a slot, what handles the buttons click event (Slots, QPushButton) Then use the QTabWidgets setCurrentIndex function like yourTabWidget->setCurrentIndex(2);

Qt4/PyQt4 - Can not set the default font for QTextDocument

谁都会走 提交于 2021-01-28 18:41:49
问题 My code is like this: from PyQt4 import QtGui doc = QtGui.QTextDocument() d_font = QtGui.QFont('Times New Roman') doc.setDefaultFont(d_font) cur = QtGui.QTextCursor(doc) cur.insertText('sample text') writer = QtGui.QTextDocumentWriter() writer.setFormat(writer.supportedDocumentFormats()[1]) writer.setFileName('CV') writer.write(doc) The 'sample text' in the output is still 'Sans' on my computer rather than "Times New Roman'. I have made sure my computer has 'Times New Roman' font. I suspect

QWizard: Change height/dimensions of title field

白昼怎懂夜的黑 提交于 2021-01-28 12:26:59
问题 I'm currently trying to implement a simple "First steps" Wizard for a Python/Qt application I'm working on. This is really easy to do with Designer, but as usual the devil lies in the details. My problem is that the 'Title' field is way too big for me (~50% of the available screen estate). Here is a screenshot, and there the *.ui-file. I've already had a look at all the QWizard/QWizardPage properties and couldn't find anything that referred to the size/styling of the 'Title' field. Is there

QWizard: Change height/dimensions of title field

杀马特。学长 韩版系。学妹 提交于 2021-01-28 12:18:56
问题 I'm currently trying to implement a simple "First steps" Wizard for a Python/Qt application I'm working on. This is really easy to do with Designer, but as usual the devil lies in the details. My problem is that the 'Title' field is way too big for me (~50% of the available screen estate). Here is a screenshot, and there the *.ui-file. I've already had a look at all the QWizard/QWizardPage properties and couldn't find anything that referred to the size/styling of the 'Title' field. Is there

Access QWizardPage created by Qt Designer

余生长醉 提交于 2021-01-27 20:34:51
问题 I am using Qt Designer to create a QWizardPage. I have imported the file into Qt Creator and it runs fine so far (I can build the project and run the wizard just fine) Now I need to reimplement the isComplete function but I an unable to understand how to do it. The pages are named wizardPage{,1,2_1,_2} . I would like to know whats the best way to reimplement the isComplete() function now. 回答1: In order to overload the isComplete() function of a QWizardPage, you need to create the QWizardPage

Widget background not transparent when using QGraphicsView but transparent when using QGridLayout

蓝咒 提交于 2021-01-27 12:50:50
问题 When I was using QGridLayout to display my widgets, only the widget was shown and the part of the image that was transparent was not shown. Now I switched to using QGraphicsScene and QGraphicsView, and now my images have a gray background wherever they used to be transparent. void Piece::paintEvent(QPaintEvent *) { string image = ":/images/" + color + piece + ".png"; pixmap.load(image.c_str()); //pixmap.setMask(pixmap.createMaskFromColor(QColor(240, 240, 240))); QPainter paint(this); paint

Displaying (rendering) HTML from a string in QT

妖精的绣舞 提交于 2021-01-26 18:00:41
问题 I have html in a QString, what widget can I use to display it? (QWebView is not necessary as I dont access Internet) 回答1: QWebViews setHtml(): The QWebView class provides a widget that is used to view and edit web documents. In Qt QWebView is the widget that renders pages for you - if you don't need the networking features it provides, simply don't use them. 回答2: Depending on what HTML tags you are using, you might be able to get away with a QTextEdit . It has support for most of HTML,