Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • How can we change the file path of ini file ?

    3
    0 Votes
    3 Posts
    2k Views
    A
    You will need to move the file using other code. The file will not magically relocate.
  • Defining Path

    2
    0 Votes
    2 Posts
    1k Views
    L
    It depens what event means to you. You can add different pixmaps to QIcon using QIcon::addPixmap() or QIcon::addFile() for different modes (normal, disabled, active, selected) and states (on, off) which are then automatically displayed when the QPushButton enters a specific state and mode. If an event is something specific to your application there is no way around using QPushButton::setIcon(). If you don't want to have different pathes all over you code you could for example use a central icon pool @ class YourClass { ... public: enum Icon { StateAIcon, StateBIcon }; QIcon icon(YourClass::Icon icon) { return ...; } ... void stateAEvent() { pushButton->setIcon(icon(YourClass::StateAIcon)); } }; @ use resource aliases @ class YourClass { ... public: void stateAEvent() { pushButton->setIcon(QIcon(":/icons/stateA.png")); } }; <RCC> <qresource prefix="/icons"> <file alias="stateA.png">someFolder/someFile.png</file> <file alias="stateB.png">differentFolder/subFolder/someFile.png</file> ... </qresource> </RCC> @
  • Highlight tree item

    5
    0 Votes
    5 Posts
    3k Views
    W
    Your explanation is a little confusing, but I'll give it a shot. I'm assuming that what you're trying to do is, based on certain criteria, highlight an element in your QTreeView. What I've found helpful in applying special attributes to elements in a QTreeView (or any of the Qt Model Views) is to add a delegate that draws the cell in a special way. I usually use QModelIndex::data and QModelIndex::setData to set and test these criteria. So, for example, in my delegate (see QItemDelegate and its examples) I may do something like @if ( index.data( Qt::UserRole + 5).toBool() == true ) painter->fillRect( option.rect, Qt::green); // that will draw the background cell in the special highlight color.@ One nice thing about this approach is that the QItemDelegate will only draw if the node is visible. You get that part for free.
  • Managing keyboard focus in a multi-dock/multi-dialog application.

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Debugging with message boxes using a widget application?

    7
    0 Votes
    7 Posts
    4k Views
    P
    Thank you all for the replies. Will be trying the style I wanted initially and then probably break points followed by qDebug. Cheers
  • Updater

    7
    0 Votes
    7 Posts
    2k Views
    P
    Have you read link? If you include your resources with the separate dll build as a plugin you will be able to modify this resources through replacing this plugin. But there is such thing as Resource Hacker. It can modify resources even if they are built-in. So if you're really need to forbid modifying than yes, you have to use some encryption.
  • Qt Syntax Questions

    12
    0 Votes
    12 Posts
    4k Views
    A
    Okay. Thanks! -Arukas
  • Basic Widgets Functionality Questions

    2
    0 Votes
    2 Posts
    1k Views
    K
    welcome to devnet Have you seen already "the example page?":https://qt-project.org/doc/qt-4.8/all-examples.html Also there are plenty of "tutorials":https://qt-project.org/doc/qt-4.8/tutorials.html around.
  • How can my application accept Greek Language?

    3
    0 Votes
    3 Posts
    2k Views
    L
    [quote author="annatz" date="1331050523"]i would like my application to display the labels at Greek language. Is there a way to do that?[/quote] There should be no problems to display Greek or any other unicode characters. You can select language from Edit > Translation File Settings... in Qt Linguist. It is very simple but as Andre said it will be better first to have a look at the documentation.
  • QMDIArea, addSubWindow steals the focus from other applications

    13
    0 Votes
    13 Posts
    7k Views
    M
    Update: Add the following line right after line 53 in test_gui.C: mw.setAttribute( Qt::WA_X11DoNotAcceptFocus ); This will prevent Qt from stealing the keyboard focus (Qt 4.7 and later, Qt 4.6.3 needs to be patched for this). Unfortunately the demo app still pops to the front in your window manager (just without keyboard focus). -> not perfect yet If you also add: mw.setWindowFlags( Qt::WindowStaysOnBottomHint ); then the window won't pop up any more, but unfortunately you can not get it to the front at all any more. :( -> bad idea Another issue in QMdiArea can be reproduced when one adds the following line right after sub->showMaximized() in line 38 in TestMainWindow.h: sub->lower(); When you now call ./test_gui 2 1 1, then you will see a tabbed view with 1 subwindow maximized and 3 windows on top of it. Best regards, Mirko
  • OpenGL demos in Qt 4.8 don't compile

    12
    0 Votes
    12 Posts
    16k Views
    G
    The demos included in SDK 1.2 seem to have a couple of issues when compiled with 4.8. In 4.8, OpenGL/glu.h is now intentionally no longer included within <QtOpenGL>, and programs that use it must include it themselves. For more info, see https://bugreports.qt-project.org/browse/QTSDK-1022 Adding #include "OpenGL/glu.h" after the other includes in qtbox.h in the boxes source tree fixes the problem without having to modify the main Qt headers. Also, if you try to compile the demos.pro project, you will need to comment out the "#include <private/qpixmapdata_p.h>" line of the arthurwidgets.cpp file in the shared folder of the demos.
  • 0 Votes
    2 Posts
    1k Views
    K
    welcome to devnet There has been a "similar post":http://qt-project.org/forums/viewthread/15128 today.
  • QPushButton don't show background image in other windows pc

    10
    0 Votes
    10 Posts
    4k Views
    K
    try this in mian.cpp QStringList libs; libs<<a.applicationDirPath()+"/plugins/"; a.setLibraryPaths(libs); In Your application folder create folder plugins\imageformats copy qjpeg4.dll to imagefromats dir best reagrds
  • How to contact DHCP server using Qt

    2
    0 Votes
    2 Posts
    5k Views
    L
    Use "QtNetwork Module":http://qt-project.org/doc/qt-4.8/qtnetwork.html for all network related features. There are also a couple similar discussions at Qt Dev Net.
  • [SOLVED] Nasty String Ending

    6
    0 Votes
    6 Posts
    3k Views
    D
    You're right. The data is in the QByteArray. QDebug is just not able to show what is in there but the size is obviously 4. These 4 Bytes consist of an STX (0x02) Byte then 2 Byte for the uint16 and finally the ETX (0x03) Byte. So first I have to check the QByteArray if it was transmittet correctly with the STX-ETX Chain and extract the 2 Bytes in the mid. Finally I get a QByteArray with my 2 Bytes. I put them together in an traditional way like this: @uint16 myValue = valueArray[1] | (valueArray[0] << 8);@ This works so far altough I get 2 warnings I don't understand for this and a similar tag: @while(valueArray[0] != 0x02) valueArray.remove(0,1);@ bq. warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: If I try to convert the 2 Bytes with your method like this: @quint16 = reinterpret_cast<quint16>(valueArray.constData());@ I get this error: bq. error: cast from 'const char*' to 'quint16' loses precision But anyway, thx for the help until here!
  • Undefited reference to 'vtable for Notepad'

    7
    0 Votes
    7 Posts
    3k Views
    A
    If you have only *.h header file you need to write realization in there or split it for 2 files one *.cpp and one *.h. Also Notepad class is inherited QMainWindow in header you wrote : public QMainWindow, and in *,cpp you need to write @Notepad::Notepad(QWidget * parent) : QMainWindow(parent)@ This may be help.
  • [SOLVED] Undefined symbol: _ZN9QlistData11detach_growEPii

    5
    0 Votes
    5 Posts
    18k Views
    M
    If you gt a message like this, invoke "c++filt" with the undefined symbol. It will tell you the plain C++ name of the symbol. Usually, that is much easier to understand: c++filt _ZN9QlistData11detach_growEPii
  • Creating a basic COM object

    3
    0 Votes
    3 Posts
    2k Views
    F
    Sorry, I have no idea on it. I'm not sure if this can give you a little help. I useally use QAxContainer to process Com involved issues
  • TextEdit and Resizing

    3
    0 Votes
    3 Posts
    2k Views
    D
    What do you have problems with?
  • QGLWidget and Inheriting from it ?

    2
    0 Votes
    2 Posts
    984 Views
    A
    any idea ?