Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.9k Posts
  • QVector<QRect> QRegion::rects() const : what's behind?

    2
    0 Votes
    2 Posts
    2k Views
    V
    Good idea for find out how something works - look to source code. ;)
  • [Solved] Help using QStandardItemModel

    10
    0 Votes
    10 Posts
    3k Views
    S
    Read manual. @ QTableWidgetItem *item = new QTableWidgetItem; item->setData(QVariant(), Role); item->setIcon(path); @
  • Qt Creator plugin development - howto

    2
    0 Votes
    2 Posts
    3k Views
    T
    Check an existing plugin that does something similar to what you want to do. No, users of a plugin do not need to recompile their creator to use a new plugin. The plugin must be build with exactly the same settings used to build the creator with. This includes compiler, Qt version, etc. I'd recommend downloading the source packages of Qt Creator and working from there. The headers needed to address functionality in the other plugins tend not to get installed. Stop by in IRC if you have questions. #qt-creator on the freenode network.
  • Win API WaitForMultiple Thread Crashing Application

    6
    0 Votes
    6 Posts
    3k Views
    M
    [quote author="Keozon" date="1337268649"]Also, I had read about the NULL terminator issue, but it didn't seem to cause any issues, so I ignored it.[/quote] If your old code, which did not care about the required NULL terminator, worked, then this was sheer luck...
  • Strange File Buffer Behavior, Windows 7

    10
    0 Votes
    10 Posts
    6k Views
    K
    Okay, so, after several days of trying to figure out the source of the problem, I conclusively determined that the problem lies in the Windows Write Cache buffer, NOT the application buffer. Sadly, I cannot turn off the Write Cache Buffer on my disk (virtual, RAID 10E, not supported by driver, evidently), so I had to find a way to flush the buffer. Calling FlushFileBuffers() didn't work, because that requires GENERIC_WRITE access to the file, which I cannot get, since the application generating the file doesn't have SHARE_FILE_WRITE mode on. So, I scoured the internet, and it was far harder than it had any right to be, but here is the solution, if anyone ever has a similar issue. Its in C#, but the answer is valid for anything. The exact specifications of the problem are well spelled out, and his findings with explorer agree with mine. "Link":http://stackoverflow.com/questions/3540801/filesystemwatcher-does-not-report-changes-in-a-locked-file Once I get the completed code, I'll post it here.
  • Setting focus to a running QProcess

    8
    0 Votes
    8 Posts
    10k Views
    V
    So I have somewhat figured it out...and I am kind of stuck but I think I know why. Here's what I did. @ /* // app button clicked (slot) */ void Widget::appButtonClicked() { // get sender of the signal QToolButton *button = qobject_cast<QToolButton *>(sender()); for (i=0;i<processList.size();i++){ // check if the process is already open QStringList objectNameSplit; objectNameSplit = QString(processList[i]->objectName()).split("*"); if (objectNameSplit.size() > 1){ if (objectNameSplit[0] == button->objectName()){ Q_PID pidQt = (Q_PID)QString(objectNameSplit[1]).toInt(); EnumWindows(EnumWindowsProc, (LPARAM)pidQt); // get the window handles return; } } } // format the exe location QString temp = button->objectName(); temp = temp.replace("/", "\\\\"); temp = "\"" + temp + "\""; QString tempWd; QStringList tempArgs; qint64 tempPid; // start the process QProcess *exeprocess = new QProcess(); exeprocess->startDetached(temp, tempArgs, tempWd, &tempPid); // set the object name for future reference QString objectName = button->objectName() + "*" + QVariant(tempPid).toString(); exeprocess->setObjectName(objectName); // append the process to the list processList.append(exeprocess); } @ When I started the process, I got the process ID. Next if the application is already open, I used the windows API EnumWindows which loops through each window until call false within the callback functions. Here is the standard windows api call back function: @ /* // window enumeration callback (GLOBAL FUNCTION NOT IN CLASS) */ BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) { // get the window process ID DWORD searchedProcessId = (DWORD)lParam; DWORD windowProcessId = 0; GetWindowThreadProcessId(hWnd,&windowProcessId); // check the process id match if (windowProcessId == searchedProcessId){ ShowWindow(hWnd, SW_SHOW); return FALSE; } return TRUE; //continue enumeration } @ where I pass in the process ID...If it matches, then I return false and stop the enumeration loop. Unfortunately the ShowWindow function fails to bring the window to the foreground... Question, when QProcess starts, does it handle a point to the parent process? or the child process created by the QProcess? Because I might be trying to bring the dock app to the foreground instead of the opened exectuable.
  • Qt Designer - The Single Inheritance Approach

    6
    0 Votes
    6 Posts
    4k Views
    M
    Oh, that should have been @window->exec();@ not @window.exec();@ My bad. The error message you were getting was regarding the -> vs . (not exec() vs show()) bq. I had been trying a number of variable declarations for the ImageDialog class/type and had not yet stumbled on window, though I knew there was some relationship between the two. I'm not quite sure I understand what you're saying here. The variable name window has no bearing on anything. You could just as easily have used anything else.
  • My Text Scolling class

    2
    0 Votes
    2 Posts
    1k Views
    E
    I think that i must modified this function: @void WidgetMarqueeLabel::paintEvent(QPaintEvent *evt) //fai ogni volta che c'è l'evento repaint { QPainter p(this); QPainter p2(this); if(direction==RightToLeft) { px -= speed; px2 -= speed; if (px <= (-textLength)){ px = width(); } if (px2 <= (-textLength)){ px2 = width(); } } else { px += speed; if(px >= width()) px = - textLength; } p.drawText(px, py+fontPointSize, text()); // disegna il testo alle coordinate px, py+fontPointSize p.translate(px,0); p2.drawText(px2,py+fontPointSize, text()); p2.translate(px2,0);@ but not work :(
  • Problem with static

    4
    0 Votes
    4 Posts
    2k Views
    A
    You need to use non-static method or return a static member
  • QStandardItem can only store text?

    2
    0 Votes
    2 Posts
    2k Views
    S
    @virtual void setData ( const QVariant & value, int role = Qt::UserRole + 1 )@
  • [Solved] Automatically resize QGroupBox to fit its contents.

    3
    0 Votes
    3 Posts
    15k Views
    B
    You are right! I had to add a layout. Actually, I tried that in the past but it did not work using the Preview mode of the QtDesigner (dunno why). But turns out that if I just run my program it works just fine! Thanks a lot! Cheers, Bekos
  • Role of horizontal, vertical spacer?

    3
    0 Votes
    3 Posts
    4k Views
    S
    Thank sir :) ps: I found answer, maybe someone will need it. "Your text to link here...":http://stackoverflow.com/questions/5618250/qt-horizontal-spacer
  • [SOLVED] How to find out whether child widget of QScroll Area is visible?

    2
    0 Votes
    2 Posts
    2k Views
    J
    I got an answer from "StackOverflow":http://stackoverflow.com/questions/10631067/how-to-find-out-whether-child-widget-of-qscrollarea-is-visible: I proposed the following code: @ #!/usr/bin/env python import sys from PyQt4 import QtGui, QtCore application = QtGui.QApplication(sys.argv) class Area(QtGui.QScrollArea): def __init__(self, child): super(Area, self).__init__() self.child = child self.setWidget(self.child) self.setFixedSize(100, 100) class MainWidget(QtGui.QFrame): def __init__(self, parent=None): QtGui.QFrame.__init__(self, parent) self.layout = QtGui.QVBoxLayout() n = 1 while n != 10: label = QtGui.QLabel('<h1>'+str(n)+'</h1>') self.layout.addWidget(label) n += 1 self.setLayout(self.layout) def wheelEvent(self, event): print "Wheel Event:" for child in self.children()[1:]: print child.isVisible() event.ignore() mainwidget = MainWidget() area = Area(mainwidget) area.show() application.exec_() @ And it was suggested I change the wheelEvent() method as such: @ def wheelEvent(self, event): print "Wheel Event:" for child in self.children()[1:]: print child.text(), 'is visible?', not child.visibleRegion().isEmpty() event.ignore() @ And that does the job! :)
  • Qt and GCC/G++ backwards compatibility

    2
    0 Votes
    2 Posts
    2k Views
    sierdzioS
    You should be fine. If you want to be 100% sure, you can compile Qt yourself using the newer version. This is especially a good idea for Qt5, which uses a bit of C++11 internally.
  • Error in application output

    2
    0 Votes
    2 Posts
    2k Views
    P
    Even no one replied...but still the code is working now, it was just run settings of creator which had to be checked.....:)
  • QItemDelegate::paint() - paint row based on criteria from single cell

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • [SOLVED] Make the cursor visible in QGraphicsTextItem

    7
    0 Votes
    7 Posts
    5k Views
    M
    You're welcome (:
  • Having trouble with adjust size

    2
    0 Votes
    2 Posts
    1k Views
    T
    Because you don't have a layout on the widget itself. Is there one on the Primary Key groupbox? Right click into the groupbox and add a vertical box layout (if that is missing). Then right click on the background of the widget itself and add a horizontal box layout.
  • QApplication - exec&#40;&#41; in Windows Service

    2
    0 Votes
    2 Posts
    2k Views
    L
    I'm not quite sure if I got your question correctly, but Windows services use a non-interactive window station, thus cannot have a user interface. You will have to use QCoreApplication instead.
  • Dual display with QT

    3
    0 Votes
    3 Posts
    3k Views
    E
    I use a embedded board i've resolved with QWidgetdesktop :)