Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.5k Posts
  • Switching beween Application

    3
    0 Votes
    3 Posts
    2k Views
    F
    Seems to me a problem related to the specific platform you are running on. I think the problem is that QProcess does not know if your process runs within an x server or a command line or in background. Therefore I guess it has not effective way to place the window on top, and I think this could also be complicated by having applications running on multiple desktops. Not sure if "desktop widget":http://doc.qt.nokia.com/4.7/qapplication.html#desktop can help in this case.
  • 0 Votes
    7 Posts
    4k Views
    G
    [quote author="victor.e" date="1317852440"]So, just to confirm my understanding of how this works: even though the text editor and button controls are constructed using their default constructors (in which the parent pointer is null), adding these 2 controls to the layout object and then using this layout in the main window sets the main window to be the parent of the 2 controls?[/quote] Adding a widget to a layout implies reparenting them. This is to ensure lifetime and object deletion. Only top level QObjects (which have no parent and will not be part of layouts etc) should be created on the stack, all other should be on the heap. There are some special cases where children on the stack would work, but I would never use those.
  • QComboBox > QListView

    5
    0 Votes
    5 Posts
    4k Views
    R
    I've solved so... @ QDir dir; dir.setPath (ListDir); for (int i=0;i<dir.entryList(QStringList("")).count();i++){ QString fileName = dir.entryList(QStringList("")).at(i); ui->listWidget->addItem(fileName); } @ thanks... [EDIT: code formatting, please wrap in @-tags, Volker]
  • SVG Format Images in Qt

    2
    0 Votes
    2 Posts
    2k Views
    V
    Look to [[Doc:QtSvg]] module.
  • [SOLVED] help with layout

    6
    0 Votes
    6 Posts
    3k Views
    F
    I managed it in the end! The problem was in the constructor of the UserView, that while it was setting up a layout, it was not adding widgets to it. The final code that works is therefore: @// set up a vertical layout QVBoxLayout* vLayoutMain = new QVBoxLayout( this ); setLayout( vLayoutMain ); setUpPanelMaster(); vLayoutMain->addWidget( panelMaster ); @ and now it is displayed correctly.
  • Custom cursor does not change on Mac

    5
    0 Votes
    5 Posts
    3k Views
    I
    Irfan Omair : did you find something to help me on Mac? sorry to bother you but honestly speaking I could not figure out how to do it on Mac/Cocoa
  • "Special Items" in QMenu

    6
    0 Votes
    6 Posts
    9k Views
    S
    Finally got around to implementing this using the two QMenu approach. Took awhile because a lot of the QMenu code is pretty complex and many functions aren't directly exposed in the QMenu API. The idea was pretty simple, but I had to go back and add a bunch of overrides for little things like when the mouse enters one of the internal QMenus and doesn't dehighlight any of the other actions (or vice versa). And it's pretty easy to connect to the main QMenu, so triggering the option box can emit the action from the outer menu just as the submenu does. @ import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class OptionBoxAction(QWidgetAction): class InWidgetMenu(QMenu): def enterEvent(self, event): # unhighlight neigboring actions (shouldn't this be built in?) # super(OptionBoxAction.InWidgetMenu, self).enterEvent(event) self.parent().parent().setActiveAction(None) def leaveEvent(self, event): super(OptionBoxAction.InWidgetMenu, self).leaveEvent(event) self.update() def mouseMoveEvent(self, event): super(OptionBoxAction.InWidgetMenu, self).mouseMoveEvent(event) self.update() class MainMenu(InWidgetMenu): def paintEvent(self, event): p = QPainter(self) action = self.actions()[0] # should only have one action rect = QRect(self.actionGeometry(action)) rect.setWidth(self.width()) # QActions don't automatically resize opt = QStyleOptionMenuItem() self.initStyleOption(opt, action) self.style().drawControl(QStyle.CE_MenuItem, opt, p) class CustomMenu(InWidgetMenu): def paintEvent(self, event): p = QPainter(self) action = self.actions()[0] # should only have one action rect = QRect(self.actionGeometry(action)) opt = QStyleOptionMenuItem() self.initStyleOption(opt, action) opt.text = '' # only show icon opt.icon = QIcon('./optionBox.png') self.style().drawControl(QStyle.CE_MenuItem, opt, p, self) def __init__(self, *args, **kwargs): super(OptionBoxAction, self).__init__(*args, **kwargs) self._widget = QWidget() self.setDefaultWidget(self._widget) self._menuLeft = self.MainMenu() self._menuRight = self.CustomMenu() self._menuRight.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) self._menuRight.setMaximumWidth(30) self._widget.setLayout(QHBoxLayout()) self._widget.layout().addWidget(self._menuLeft) self._widget.layout().addWidget(self._menuRight) self._widget.layout().setMargin(0) self._widget.layout().setSpacing(0) def setMainAction(self, action): self._menuLeft.clear() self._menuLeft.addAction(action) self.connect(action, SIGNAL('triggered(bool)'), self.mainTrigger) def getParentMenu(self): return self._menuLeft.parent().parent() _parentMenu = property(getParentMenu) def mainTrigger(self, checked): self._parentMenu.hide() self._parentMenu.emit(SIGNAL("triggered(QAction*)"), self._menuLeft.actions()[0]) def setCustomAction(self, action): self._menuRight.clear() self._menuRight.addAction(action) self.connect(action, SIGNAL('triggered(bool)'), self.customTrigger) def customTrigger(self, checked): self._parentMenu.hide() self._parentMenu.emit(SIGNAL("triggered(QAction*)"), self._menuRight.actions()[0]) app = QApplication(sys.argv) window = QMainWindow() testMenu = QMenu("Test") add a submenu subMenu = testMenu.addMenu('Sub Menu of Options') subMenu.addAction('Option #1') subMenu.addAction('Option #2') add the action (with the option box) optionBoxAction = OptionBoxAction(testMenu) optionBoxAction.setMainAction(QAction('Test', testMenu)) optionBoxAction.setCustomAction(QAction('Never render this', testMenu)) add some other actions testMenu.addAction(optionBoxAction) testMenu.addAction('Really Long Action') testMenu.addAction('With checks').setCheckable(True) def triggerEvent(action): print('Event triggered: %s' % action.text()) wire up the QMenu (should automatically connect signal in 'optionBoxAction') QObject.connect(testMenu, SIGNAL('triggered(QAction*)'), triggerEvent) window.menuBar().addMenu(testMenu) window.show() app.exec_() @
  • No Keyboard input if QLineEdit on frameless popup window

    3
    0 Votes
    3 Posts
    3k Views
    R
    Unfortunately that doesn't work. Tried it on OSX.
  • QGLWidget in a plugin

    3
    0 Votes
    3 Posts
    2k Views
    Z
    I load plugin by clicking the button in the main window thus QApplication was already created by this moment. Just tell me if you have successfull practice in using QGLWidget in a plugin. I don't know if it is bug in my application or QGLWidget cannot really be used in a plugin. EDIT: Really, I use the class that has QGLWidget as a subclass. Tried to use QGLWidget instead. Everything ok. So the problem is in plugin.
  • [SOLVED] from qaction to qpushbutton?

    9
    0 Votes
    9 Posts
    12k Views
    F
    I guess the problem here is not about how QAction is appropriate for a QPushButton, but if there is the need for a common "action" to use for a set of commands. I guess there is! And maybe having a look at how other toolkits implement this (e.g., the command framework of RCP) could be a good starting point for a refactoring/implementation fot qt5.
  • 0 Votes
    3 Posts
    3k Views
    E
    Thanks for your response. I posted this question on "stackoverflow":http://stackoverflow.com/questions/7650978/qnetworkreply-emits-error-signal-twice-when-contentnotfounderror-occures-when-eve also and got a solution for it. To sum it up: Replace test() with this: @void test() { qRegisterMetaTypeQNetworkReply::NetworkError("QNetworkReply::NetworkError"); mgr = new QNetworkAccessManager(this); reply = mgr->get(QNetworkRequest(QUrl("http://developer.qt.nokia.com/fileNotExisting.txt"))); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(onError(QNetworkReply::NetworkError)), Qt::QueuedConnection); }@ There is a bug that will be fixed in the release of Qt version 4.8.0 ("link":https://bugreports.qt.nokia.com/browse/QTBUG-16333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel)
  • Multithreaded opengl

    5
    0 Votes
    5 Posts
    8k Views
    A
    bms, thanks for your input. I've browsed the interwebs and one of the better explanations I found was by apple: http://developer.apple.com/library/mac/#documentation/graphicsimaging/conceptual/OpenGL-MacProgGuide/opengl_threading/opengl_threading.html I will try to implement something like the "Worker Task" idea from that link. If anyone has some example code where a (double-buffered?) vertex-array or vertex-buffer-object is updated in a worker task I would be interested. Anders
  • [Solved] specify different context to tr?

    3
    0 Votes
    3 Posts
    3k Views
    D
    Thanks Volker, it worked :)
  • Qt 4.8.0 release timeframe?

    5
    0 Votes
    5 Posts
    3k Views
    H
    We just rolled back from 4.8.0 because the network access manager was not properly handling "Connection: close" in the HTTP header. This resulted in a TCP reset when the next post was made over the connection, and the post sailed off into the ether. There is an official bug # but I have to wait until I get to work to post it here. As of last week it hadn't even been looked into. This is a pretty big problem for us. We rolled back to 4.7.4 on Monday. Edit: here's the bug: "20924":https://bugreports.qt.nokia.com/browse/QTBUG-20924
  • Peer to Peer Connection

    6
    0 Votes
    6 Posts
    10k Views
    A
    A p2p setup is nothing more than a situation where every node in a network can act as both a server and a client. No magic involved there. It depends a bit on what you are after. Is your application limited to two nodes? Do you know the address and port where you expect each of the applications to be listening? A server is nothing more than an application that accepts incomming connections. Once a connection is established, both sides can be equal in functionality: data can flow both ways on a TCP connection. The only challenge you face, is to come up with a system to establish that first connection. I have used UPD broadcast messages for that in the past, but a better solution is of course to use something like Zeroconf for service registration and discovery.
  • Win7 read-only problem

    3
    0 Votes
    3 Posts
    3k Views
    K
    Are you trying to change the attributes of special directories such as program folders? In Win 7 and already Vista this is restricted now. So, that might be a reason for your problems. In some cases you need admin rights.
  • Adding new UI forms to the Application for additional windows

    3
    0 Votes
    3 Posts
    3k Views
    L
    I am familiar with the problem ,you have to instantiate your widget with 'new' statement
  • Newbie Tabpage delete

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • QTestlib: Testing QTreeView rename action

    2
    0 Votes
    2 Posts
    3k Views
    A
    I solved this problem by Mocking my Views/Qt stuff via googlemock
  • QTreeView branch rendering

    3
    0 Votes
    3 Posts
    4k Views
    J
    Indeed. And it wasn't that I wanted to be messing around with style sheets. It was rather the case that style sheets seemed to be the "suggested" way to make the tree view draw its branches. If there is a better/simpler way to get that, I'm all in favor of it!