Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • Window focus with process pointer

    4
    0 Votes
    4 Posts
    3k Views
    K
    I think that is not possible, if you are using QProcess. What you could do is to display all information in a QTextBrowser window, when the user clicks again. However, you need to handle also additional commands input by the user then.
  • [Split] Qt and iOS/Objective-C

    4
    0 Votes
    4 Posts
    4k Views
    U
    In respect of non-Apple Objective-C SDKs, there is actually a project called "GNUstep":http://www.gnustep.org/ -- probably the only one other than frameworks from Apple that does so. The project originated from NeXTSTEP, which is the precursor of Cocoa, so GNUstep shares many similarities with Cocoa (and Cocoa Touch). But this project is far from satisfying on any platforms, and is certainly not suitable for productivity use.
  • QDataStream and QByteArray as a buffer

    5
    0 Votes
    5 Posts
    16k Views
    D
    Yes (remember that QByteArray isn't a QIODevice, thus QDataStream creates a QBuffer internally).
  • [SOLVED] Need to show Only File System folders in QTreeView.

    10
    0 Votes
    10 Posts
    10k Views
    M
    Thanks cincirin...its working fine with fileSystemModel->myComputer().. and Thanks to all
  • 0 Votes
    2 Posts
    4k Views
    napajejenunedk0N
    Found a workaround: Set the QLineEdit's font to have pixel size equivalent to the height of the QLineEdit widget. Do this in the showEvent function of the class that wraps the QGraphicsView, QGraphicsProxyWidget and QLineEdit or in the showEvent function of a QLineEdit subclass. Save this pixel size to a member variable. Detect the view scaling. In the detection function set the pixel size of the QLineEdit's font to be equal to the cached font pixel size ( point 1) ) multiplied by the uniform view scale ( make the view scale uniform ). Scale down the proxy widget by 1.0 / scale.
  • [Solved] incorrect calculation in Qt Script

    9
    0 Votes
    9 Posts
    6k Views
    Z
    Also, the trigonometric functions are transcendental functions and so cannot be calculated exactly. All implementations use approximations that are good to some degree of accuracy for a range of inputs. As Andre suggested, test it with an epsilon (small value) to see if it is in agreement with your criteria. i.e. @ const double eps = 1.0e-10; // as an arbitrary example double value = sin( pi ); // pi defined somewhere else const double test = 0.0; if ( qAbs( value - test ) < eps ) qDebug() << "Values agree within some small value epsilon"; @ Obviously you can use different values for eps and test as needed in your particular cases. This is just a fact of life when working with floating point representations on machines with limited memory.
  • Unix command slot creation

    9
    0 Votes
    9 Posts
    5k Views
    sierdzioS
    [quote author="fluca1978" date="1317638423"]Sorry, I was not saying it is absolutely a bad idea to use QProcess, but that it could be a bad idea for a lot of cases where Qt already provides a wrapping for doing the same task. [/quote] And you're perfectly right here :) Cheers.
  • QThread::terminate doesn't work

    4
    0 Votes
    4 Posts
    4k Views
    D
    @class MyThread: public QThread { public: void setFoo(Foo *foo) { _foo = foo; } void run() { _foo->loop(); } private: Foo *_foo; }; class Bar { public: void doSomething() { _thread->setFoo(); _thread->start(); } slots: void terminate() { // If we can't terminate with normal way - will use hard termination, timeout will exeucte hardTerminate timer.singleShot(1000, this, SLOT(hardTerminate())); // Normal termination _foo->terminate(); // Waiting thread _thread->wait(); // Thread finished, cancel timer timer.stop(); } void hardTerminate() { // Ooops, normal termination failed, will terminate thread _thread->terminate(); } private: Foo *_foo; MyThread *_thread; QTimer _timer; @
  • How to get QChar from KeyPress using WinAPI?

    3
    0 Votes
    3 Posts
    3k Views
    Z
    I think, @GetKeyboardState(keyboardState);@ already includes VK_SHIFT state. If so, How can I set VK_SHIFT in keyboardState? For reason, I'm writing windows hook keyboard Input program with Qt. So, I have no choice to use WinAPI. Thanks
  • QT timing accuracy

    12
    0 Votes
    12 Posts
    9k Views
    L
    On Windows (and other non-hard-realtime kernels) there will be always jitter, no matter how sophisticated your multithreaded design is. I have to disagree with the example in the previous post. Combine the polling approach with highest thread priority and your application will massivly burn CPU time (which could have been spent doing some useful work). You might get slightly more accuracy but querying the performance counter doesn't help much if your thread is suspended anyways. I think the best approach would be to store the values in memory instead. This will provide the most accurate timestamps as it is the fastest and most exclusive storage available. Transfer the data from memory to disk at reasonable intervals (I think of seconds here, not milliseconds). If you want to make sure your data has been written to disk don't forget to flush. If you need failsafe logging or guaranteed response times for generating exact timestamps Windows is not the way how to do it anyways.
  • Can i use windows API in Qt?

    4
    0 Votes
    4 Posts
    7k Views
    L
    Qt is built on top of native system APIs (Windows SDK, Carbon, Cacao, ...). Each of these APIs use their own types of identifiers (HWND, HIViewRef, NSView, ...), whereas Qt provides a platform-independent identifier (QWidget*). If you now want to use platform-specific API you will have to use a platform-specific identifier - this it what QWidget::winId() does. It returns a platform-specific identifier (HWND on Windows, HIViewRef or NSView on Mac OS X, ...). As long as you pass this platform-specific identifier to platform-independent functions like QWidget::find() your application will remain portable. As soon as you pass it to a platform-specific function, for example GetWindowText(), your application is no longer platform-independent as the GetWindowText() function is part of the Windows SDK which is only available on Windows (but not on Mac OS X, ...).
  • Problems with Qt and strange caracters!

    10
    0 Votes
    10 Posts
    4k Views
    A
    The encoding you save the text in, should match the encoding you try to load it from (or the other way around, of course). If you read the source code of the example, you can also see that it is dealing with encodings (lines 408-410). However, the code there mainly seems to try to deal with HTML encodings, not encodings of text files. You should investigate what the default codec is that is returned from the method in line 408 for a non-HTML file. If you store your file in that format, it will be loaded and displayed correctly. Note that this is nothing like using a translation file though.
  • Implementation of thread

    8
    0 Votes
    8 Posts
    4k Views
    S
    Yup :). I think i need to read it once again.
  • Speaking Applications

    7
    0 Votes
    7 Posts
    3k Views
    L
    I want to use QxtRPCPeer in the PEER mode. Where can I get a simple example of its use?
  • [Solved] Win32 API hook implemenation problem.

    3
    0 Votes
    3 Posts
    4k Views
    Z
    Yes, Sorry, I use wrong function. :D I solve it.. Thanks
  • [Moved] new to Qt development

    11
    0 Votes
    11 Posts
    4k Views
    G
    [quote author="Andre" date="1317547623"]I'm not so sure about that. I think you can just spin a QEventLoop from any thread, QThread or not. Sure, QThread has it build in, but I don't think there is much magic involved there. Once you have a running eventloop, you can use slots in the thread, right?[/quote] Yes, it should be that way. If a QObject class is created inside a thread that is not a QThread (like the main thread) a pseudo QZhread object is created and it works.
  • [Solved] How can i call two slot using timer alternately?

    5
    0 Votes
    5 Posts
    3k Views
    AlicemirrorA
    I think that a faster way maybe a single function with a flag. You should only set the negation of the flag inside the slot and fire it every timer trigger. Then the flag indicate the way the slot function should follow.
  • How to build simple filmstrip component in Qt for viewing picture slides?

    5
    0 Votes
    5 Posts
    3k Views
    A
    Sure, it can be done using pure c++. Or you can use all the work already done by the Quick team and create a widget that is internally using QML to do the same with less work. Really, Quick is made for this kind of graphic UI stuff, and Quick 1 can be easily mixed with classic C++.
  • Connection between multiple widget in designer

    3
    0 Votes
    3 Posts
    2k Views
    A
    Personally, I think that you need to re-think that UI. Sounds like hell to use a UI like that. Why don't you put the 200 items in a list view themselves? You do realize that list views can also display checkboxes, don't you. That way, you can at least provide sorting and filtering on the list, so your users can actually find the items they need from it. If you use a model-view approach to begin with, then displaying a list that only contains the items checked in the other list is trivial. You only need a QSortFilterProxyModel to filter on the checkstate role.
  • Circumventing QTextDocument restriction to single-line regex search

    2
    0 Votes
    2 Posts
    3k Views
    A
    This reads like a nice howto. Would you considder putting the above in a page on the wiki?