Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.9k Posts
  • [SOLVED] How to make Qt include source files/folders in compiled file? C++

    16
    0 Votes
    16 Posts
    7k Views
    W
    Well the best that could happen to me was that I could 'store' the helpcollectionfile (qhc) in a resourcefile (qrc). So it can easily be distributed. Cause this application is going to be used by hundreds, maybe thousands of users. And then it would be much easier to get it in just one executable. My colleague is coming back next week, i'll ask him if he has a decent solution. But thanks for the help anyway :) Great forums here
  • How to change style sheet of arrow buttons in QDateEdit?

    4
    0 Votes
    4 Posts
    4k Views
    A
    Qt Creator has a resource editor you might use, but you can also hand-craft resource files. It is a simple XML format. This is a sample from the documentation: @ <!DOCTYPE RCC><RCC version="1.0"> <qresource> <file>images/copy.png</file> <file>images/cut.png</file> <file>images/new.png</file> <file>images/open.png</file> <file>images/paste.png</file> <file>images/save.png</file> </qresource> </RCC> @ However, just to try if it works with images, you can also just leave them on the file system and provide the correct path. If it works, you can stick the images in a resource and compile the images into your application that way. Note that I am not sure that this is your solution.
  • Showing content of a file in the tabs

    3
    0 Votes
    3 Posts
    1k Views
    P
    Hello, I used tree to show my data in tree view in my tabs, which existed in main window. I think I may need a parser to pares my data, which are on the newly created file, also using setupModelData method in treeModel.cpp, and add it to my tree model. I am still worḱing on it.
  • QRegExp use find forward slash(/) and backward slash(\)

    4
    0 Votes
    4 Posts
    6k Views
    D
    the forward slash / has no special meaning in regular expressions. @QRegExp rx("([a-zA-Z]:[\\/]|[\\/]{2})");@ works for both backward and forward slashes. (Note I've removed the whitespace character from the drive letter) But beware, you should also allow unix paths like "/home/dermanu", so possibly group "[a-zA-Z]:" together and make it optional by appending a "?" character
  • QSettings doesn't create the INI file

    3
    0 Votes
    3 Posts
    6k Views
    T
    Hi, I think sync() will write to file only if you used QSettings::setValue(). Reading values does not change file, so sync() does not need to write it.
  • Phonon on Mac crash

    2
    0 Votes
    2 Posts
    2k Views
    J
    I also met a problem in using phonon on mac, but it came up after I quit the QT example app(QTmediaplayer.app). Did you met the problem likes me?
  • QFileDialog::getExistingDirectory dialog display in center of widget

    4
    0 Votes
    4 Posts
    3k Views
    F
    [quote author="mathi77in" date="1336551528"]i want display dialog box in center of parent widget(main window)[/quote] It could be an OS specific behavior.
  • [Solved] one problem with QDialogButtonBox

    3
    0 Votes
    3 Posts
    2k Views
    N
    It's OK now.Thank you
  • [SOLVED] the qt-way for creating sqlite-databases

    6
    0 Votes
    6 Posts
    6k Views
    C
    [quote author="jstaniek" date="1336511641"]Hi, Have a look at Predicate lib which has SQLite3 plugin: http://community.kde.org/Predicate It's Qt-only, LGPL, and unlike QtSQL it 'knows' how to create database and then new tables (has a Qt/C++ API for that). No need to pass SQL at all (but it can be if you wish). I am preparing this lib as a next get backend for Kexi and similar complex apps. The only downside - it's not yet released and its API isn't frozen, so you'd need a copy of it.[/quote] Thanks, this sounds like exactly what I have been looking for. Unfortunatly I'd prefer to avoid any dependencies (except Qt itself) as much as possible. I just hoped that there simply is a qt-api for my case that I simply couldn't find. I will accept that there is no api by qt, so I will do it by hand with SQL-commands. [quote author="Rahul Das" date="1336509988"]You might want to go through the "MVP":http://qt-project.org/doc/qt-4.8/model-view-programming.html as well.[/quote] I don't know what for since it doesn't have to do with my "problem".
  • [SOLVED]QProgressBar stylesheet problem

    4
    0 Votes
    4 Posts
    5k Views
    S
    [quote author="glararan" date="1336503116"]I add it to code...nothing changed EDIT:SOLVED[/quote] Hi, You need to EDIT your first post and append SOLVED if you got the answer. If not then you can provide your code so that we can figure out the above behavior of the progress bar. As it has already been explained above that stylesheets mostly deals with the look and feel of the component. Thanks :)
  • MousePressEvent goes to Parent when pop up is visible

    4
    0 Votes
    4 Posts
    4k Views
    M
    Well, on the Windows platform the default/expected behavior is that a context menu does not block mouse click events for the underlying widget (only a modal dialog would do that). The behavior on Mac OS X may be different (can't check, because I don't have a Mac available), but this doesn't mean that the behavior on Windows is "wrong". You will probably have to implement your own workaround or change your code to work on Win32 too...
  • [Solved]across platform

    8
    0 Votes
    8 Posts
    3k Views
    P
    thank you guys, the problem is fixed. the trick is: @ QString sym; const ushort array = sym.utf16(); int intValue = (int*)array; @
  • [Solved]Link error

    4
    0 Votes
    4 Posts
    2k Views
    P
    thanks a lot, the problem is fixed because of the wrong place where I put .o in. the solution is just to remove the subfolder of the debug and release @CONFIG(debug, debug|release){ LIBS += -L../AppLibrary-build-desktop -lAppLibrary -L../BusinessObjects-build-desktop -lBusinessObjects } CONFIG(release, debug|release){ LIBS += -L../AppLibrary-build-desktop -lAppLibrary -L../BusinessObjects-build-desktop -lBusinessObjects }@
  • Writing app for multiple Linuxes

    4
    0 Votes
    4 Posts
    2k Views
    T
    The "LSB":http://www.linuxfoundation.org/collaborate/workgroups/lsb is supposed to make that straight forward. Qt is defined there as part of the desktop area, so that should help. Of course the Qt in there is rather old... (IIRC 4.2 or something), so you might want to go for something else. I usually just decide which distributions to support and then do the building on the oldest distribution and the majority of testing on the newest. That works most of the time, but you really need to document which libraries you need and make sure all of them are available. I use "schroot":http://alioth.debian.org/projects/buildd-tools a lot, which allows to have several distributions installed into chroot environments (think: directories:-). Those are a huge help to find library compatibility issues and run at native speed -- much faster than VMs.
  • [SOLVED] (Beginner) Very simple XML Parser

    10
    0 Votes
    10 Posts
    7k Views
    P
    The .lib is in the right directory (4.8.1) now, thanks! I didn't know tha there was this update. I've got problems for the Path setup, Is it different now? I've tried: in User variables : @PATH : C:\QtSDK\Desktop\Qt\4.8.1\msvc2010\bin;C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin@ and @QTDIR : C:\QtSDK\Desktop\Qt\4.8.1@ and @QMAKESPEC : win32-g++@ (don't know whether it's used) like I've seen: http://sector.ynet.sk/qt4-tutorial/preparations.html But I can't build: @The program has unexpectedly finished. C:\test\test2\debug\test2.exe exited with code -1073741511@
  • Communicating between Widgets without parent casting

    23
    0 Votes
    23 Posts
    11k Views
    D
    [quote author="TheDestroyer" date="1336490799"]The thing is that the way those GUI's work is different. That's why I could expect a different behaviour.[/quote]Not in such a fundamental way. A QWidget subclass still is a normal C++ class after the moc run, and when it has a pointer member you can do with it whatever you can also do in a non GUI class. [quote author="TheDestroyer" date="1336490799"]No one knows how those meta files of the GUIs are managed..., and how they take information from other objects.[/quote]That's not right, what the meta object compiler does is relatively transparent when you look at the outputted moc_ files. No magic going on, it just adds some homebrew RTTI class and boilerplate code to every QObject class to make sigs/slots work. Specifically, it does not touch your settings pointer member. I've tried it. Here are three files: main.pro, main.h and main.cpp: main.pro: @QT += core gui TEMPLATE = app HEADERS += main.h SOURCES += main.cpp@ main.h: @#ifndef HEADER_H #define HEADER_H #include <QtGui> class Settings { public: Settings():intValue(0), boolValue(false) {}; ~Settings() {} int intValue; bool boolValue; }; class QTestWidget : public QWidget { Q_OBJECT public: explicit QTestWidget(QWidget *parent, Settings *settings); protected: virtual void paintEvent(QPaintEvent *event); private: Settings *mSettings; QTimer mRenderTimer; }; class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow() { delete mSettings; } private slots: void changeBoolSetting(); void changeIntSetting(); private: Settings *mSettings; }; #endif // HEADER_H@ and main.cpp: @#include "main.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); } // === Implementation of MainWindow, QTestWidget and Settings === MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), mSettings(new Settings) { setGeometry(50, 50, 100, 110); QTestWidget *tw = new QTestWidget(this, mSettings); QPushButton *b1 = new QPushButton(this); QPushButton *b2 = new QPushButton(this); tw->setGeometry(5, 5, 90, 70); b1->setGeometry(25, 75, 25, 25); b2->setGeometry(50, 75, 25, 25); connect(b1, SIGNAL(clicked()), SLOT(changeBoolSetting())); connect(b2, SIGNAL(clicked()), SLOT(changeIntSetting())); } void MainWindow::changeBoolSetting() { mSettings->boolValue = !mSettings->boolValue; } void MainWindow::changeIntSetting() { mSettings->intValue += 1; } QTestWidget::QTestWidget(QWidget *parent, Settings *settings) : QWidget(parent), mSettings(settings) { connect(&mRenderTimer, SIGNAL(timeout()), this, SLOT(update())); mRenderTimer.start(500); } void QTestWidget::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter painter(this); painter.drawRect(rect().adjusted(0, 0, -1, -1)); painter.drawText(rect(), Qt::AlignCenter, QString::number(mSettings->intValue)+"\n"+ QString(mSettings->boolValue ? "true" : "false")); painter.drawText(0, 13, QDateTime::currentDateTime().toString("hh:mm:ss:zzz")); }@ run qmake; make; ./main and you'll see that it works as expected. Click the two buttons and see the QTestWidget update its display (in 500ms render-intervals), depending on it's injected Settings pointer.
  • Graph based code generation. Where to start?

    1
    0 Votes
    1 Posts
    4k Views
    No one has replied
  • Save application settings

    2
    0 Votes
    2 Posts
    1k Views
    A
    I would create separate settings objects.
  • Problem with vertical alignment in QTextTableFormat

    2
    0 Votes
    2 Posts
    2k Views
    D
    Finally, if this is a bug, where should I look to fix it? For my app, table vertical alignment is crucial. Thank you
  • How to use ActiveX controls in Qt 4.7.4?

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied