Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.8k Posts
  • Removing tree node not effecting

    7
    0 Votes
    7 Posts
    2k Views
    A
    thanks a lot...:)
  • Style of focus frame

    1
    0 Votes
    1 Posts
    970 Views
    No one has replied
  • Translating supportedDocumentFormats() into string for saveFileDialog

    2
    0 Votes
    2 Posts
    1k Views
    A
    AFAIK, there is no other way than the way you describe.
  • 0 Votes
    3 Posts
    5k Views
    S
    Forgot to include that QtSDK\MinGW\bin was included in my path. Could there be something wrong with the dll?
  • Using QTreeView to compare two directories

    4
    0 Votes
    4 Posts
    3k Views
    G
    You will have to populate the model yourself. For a first try, I would go with a [[Doc:QStandardItemModel]] and store the file name and possibly path in one of the user properties. You'll have to "calculate" the contents yourself though. To ease the learning of Qt, I recommend studying the introductions and examples. For the model/view programming, you should read the more detailed guides too, even if you're not going to implement your own model at the moment. And make you some simple pet project to get accustomed to the API. For displaying the data- you have different options here: Two tree views, one for each directory - you will have to fill in dummy items for the missing files and directories then. Or a table view. But that has no nice hierarchy, though. I think you'll need to experiment a bit here.
  • Link for Downloading QT 4.7 (source)

    2
    0 Votes
    2 Posts
    2k Views
    Z
    http://download.qt.nokia.com/qt/source/
  • Anagrams with regular expression

    4
    0 Votes
    4 Posts
    3k Views
    A
    Look at "this algorithm...":http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order You need to sort the characters in the string (anagram becomes aaagmrn), and apply it. Best of luck.
  • Add a custom font

    2
    0 Votes
    2 Posts
    2k Views
    R
    Try [[Doc:QFontDatabase]]
  • [SOLVED] how to print a int and string to the status bar?

    4
    0 Votes
    4 Posts
    3k Views
    K
    thank you Lukas Geyer
  • 0 Votes
    2 Posts
    5k Views
    L
    "Drop Site Example":http://developer.qt.nokia.com/doc/qt-4.8/draganddrop-dropsite.html
  • QPluginLoader, late binding and signals/slots

    17
    0 Votes
    17 Posts
    8k Views
    L
    You cannot define signals and slots in interfaces, as you would have to subclass QObject, which will result in a non-abstract class. In addition, once your interface dervies from QObject, all classes implementing this interface derive from QObject as well, which means you cannot subclass from other QObject subclasses (like QWidget), as QObject does not support multiple inheritance (this is the problem you are currently running into). The (or one) solution is to define signals and slots in the interface, but not to subclass QObject. This does not strictily enforce the implementation of those signals and slots in interface implementations at compile time, but it enforces the implementation of the (ordinary) methods and clearly states that they have to be signals and slots in interface implementations. Signals and slots are resolved during runtime and as long as interface implementations subclass any QObject subclass they can be used. @ class SampleInterface { // Delcaring those methods as signals and slots does NOT enforce // that they are actually implemented as signals and slots in interface // implentations, but it forces at least an implementation of ordinary // methods and indicates clearly that those methods should be // implemented as signals and slots. QMetaObject (or connect()) can // be used to check if they have been actually implemented as signals // and slots during runtime. signals: virtual void sampleSignal() = 0; public slots: virtual void sampleSlot() = 0; }; Q_DECLARE_INTERFACE(SampleInterface, "SampleInterface") class SampleQObjectImplementation : public QObject, SampleInterface { Q_OBJECT Q_INTERFACES(SampleInterface) signals: void sampleSignal(); public slots: void sampleSlot() { qDebug(Q_FUNC_INFO); emit sampleSignal(); } }; Q_EXPORT_PLUGIN2(sampleQObjectImplementation , SampleQObjectImplementation) class SampleQWidgetImplementation : public QWidget, SampleInterface { Q_OBJECT Q_INTERFACES(SampleInterface) signals: void sampleSignal(); public slots: void sampleSlot() { qDebug(Q_FUNC_INFO); emit sampleSignal(); } }; Q_EXPORT_PLUGIN2(sampleQWidgetImplementation , SampleQWidgetImplementation) // Connect to slots and signals using QObject as base class pointer // (as returned by QPluginLoader::instance()) QObject* sampleQObjectImplementation = new SampleQObjectImplementation; QObject* sampleQWidgetImplementation = new SampleQWidgetImplementation; QObject::connect(sampleQObjectImplementation, SIGNAL(sampleSignal()), sampleQWidgetImplementation, SIGNAL(sampleSlot())); // Cast to SampleInterface to call methods directly SampleInterface sampleInterface = qobject_cast<SampleInterface>(sampleQObjectImplementation); sampleInterface->sampleSlot(); @ Brain to terminal. Not tested. Exemplary. A variation to this idiom is to add a <code>QObject *object() { return this; }</code> method to the interface, which allows for using signals and slots with an interface pointer as well. @ SampleInterface sampleQObjectInterface = qobject_cast<SampleInterface>(sampleQObjectImplementation); SampleInterface sampleQWidgetInterface = qobject_cast<SampleInterface>(sampleQWidgetImplementation); connect(sampleQObjectInterface->object(), SIGNAL(sampleSignal()), sampleQWidgetInterface->object(), SLOT(sampleSlot())); @ Brain to terminal. Not tested. Exemplary.
  • How parent object affect painting to child object?

    24
    0 Votes
    24 Posts
    13k Views
    P
    [quote author="Volker" date="1325243008"] [quote author="pratik041" date="1325220949"] [quote author="Volker" date="1325183040"] Why do you paint yourself at all? What is wrong with the default provided widgets?[/quote] I have painted myself because this is the requirement provided to me. [/quote] And did you try to achieve your goal using standard widgets without painting yourself?[/quote] I am now getting proper output with both painting and without it also.
  • How can i get default focus frame in Mac for custom widget?

    5
    0 Votes
    5 Posts
    2k Views
    G
    Have a look at [[Doc:QFocusFrame]].
  • UDP : How to send a response to a client

    9
    0 Votes
    9 Posts
    12k Views
    G
    "QUdpSocket::readDatagram() ":/doc/qt-4.8/qudpsocket.html#readDatagram takes optional pointers to a [[Doc:QHostAddress]] for the address and a quint for the port. bq. Receives a datagram no larger than maxSize bytes and stores it in data. The sender's host address and port is stored in *address and *port (unless the pointers are 0). Use it to send your data back to the sender. In Qt, using [[Doc:QUdpSocket]] you can sort of connect between the server and the client and use [[Doc:QIODevice]]'s read() and write() methods. This is not a real connection like in using TCP, but kind of a "virtual connection".
  • Qt way to set FIFO map ?

    5
    0 Votes
    5 Posts
    3k Views
    U
    Thanks Andre , this is what i have implemented in the end
  • Set QAuthenticator values in other thread

    2
    0 Votes
    2 Posts
    2k Views
    T
    Solved this trouble @QObject::connect(nam, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), mainWin, SLOT(onProxyAuthenticationRequired(QNetworkProxy, QAuthenticator*)), Qt::BlockingQueuedConnection);@ Change type connection on [[doc:Qt::BlockingQueuedConnection]]
  • Multiple file edition

    7
    0 Votes
    7 Posts
    3k Views
    A
    Yes, sure that is possible. You can do such things, but you will need to handle the events yourself. Because you are using a QTabWidget, and that widget embeds QTabBar, subclassing isn't going to get you the events you need. You will need to use eventfilters. You can get a pointer to the embedded QTabBar using QObject::findChild<QTabBar*>. Then, you can install an event filter on it, and use any click the way you want it. I have used this technique to add features to QTabBar and QTabWidget that allow renaming tabs by double clicking them, and to make it possible to prevent the switch of a tab (to allow validation).
  • Qt - Skinning a QScrollBar with Paint Event?

    2
    0 Votes
    2 Posts
    2k Views
    J
    take a look "here":http://developer.qt.nokia.com/doc/qt-4.8/stylesheet-examples.html#customizing-qscrollbar
  • Problem in getting tooltip?

    4
    0 Votes
    4 Posts
    2k Views
    P
    [quote author="Anticross" date="1325161368"]Where do you set the tool tip? For some item on widget or else ? Do you use Abstract model or re-implement data method in standard model ?[/quote] Actually i was trying to show always the tooltip irrespective of the widget has focus or not. This was possible from the setAttribute function and some code was problem in event filter also.
  • Updating fixed window size

    4
    0 Votes
    4 Posts
    2k Views
    J
    Sounds like i was misunderstood. it seems that it is needed to change centeral widget's size hint, though.