Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • 0 Votes
    28 Posts
    10k Views
    A
    What did you try already. I already told you: we're not here to guide you Every. Single. Step. Of. The. Way. Did you start in that free book you were recommended already?
  • [SOLVED] QGridLayout: widget takes too much space

    5
    0 Votes
    5 Posts
    4k Views
    S
    Solved by now. Thanks all. What didnt help: setting QToolBar's sizePolicy What helped: setting QToolBar's to Minimum,Maximum and adding few Expanding QSpacerItem
  • QODBC plugin compile

    4
    0 Votes
    4 Posts
    6k Views
    S
    Thanks very much guys using your two responses i was able to fix my problem.
  • How to add a C++ object into a Qt Thread ?

    9
    0 Votes
    9 Posts
    7k Views
    A
    Note that none of the articles say that you should not subclass QThread. There are still valid reasons to do so in some cases. You just have to understand what it means if you do so, and realize that for a lot of cases, it makes more sense to move a QObject-derived worker object to a vanilla QThread.
  • QProcess managed by a separate QThread

    7
    0 Votes
    7 Posts
    10k Views
    L
    [quote author="iw2lsi" date="1333456196"] So it could be possible to start the QProcess from a slot connected to the QThread::started signal?[/quote] No, because the QThread object still belongs to the main thread. It might be a bit confusing but the QThread object itself belongs to one thread (most probably the main thread), but executes the code of its QThread::run() member in another thread. If you want to start a QProcess that has been moved to another thread the most viable solution that comes to mind is a QProcess subclass which adds a slot to start itself, which then can be called through the threads event loop either using a connection or QMetaObject::invokeMethod(), so its code is actually executed in the thread the QProcess belongs to. Before digging into multithreaded applications with Qt make sure you have read the excellent article about "Threads, Events and QObjects":http://qt-project.org/wiki/ThreadsEventsQObjects.
  • Formatting Numbers

    15
    0 Votes
    15 Posts
    8k Views
    G
    Yes it works, and with this modification also the UI is working properly. Thank you Andre for your support in this matter.
  • 0 Votes
    7 Posts
    8k Views
    K
    Depends on how you use the Dialog and where you create it. But I guess in your case you can just allocate the object on the stack. The advantage is also the disadvantage, you have to take care of deleting the object yourself. Glad I could help.
  • QAxWidget in translucent window

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • Clear the password from memory

    12
    0 Votes
    12 Posts
    8k Views
    A
    I doubt if a plugin for Qt will be detected by anti-virus programs as a threat.
  • Re-engineer the Simple Tree Model

    2
    0 Votes
    2 Posts
    2k Views
    A
    Perhaps "this":http://www.fioniasoftware.dk/blog/?p=51 will help? You can also have a look at the FlatModelProxy inside KDE.
  • QLocalServer with UAC

    2
    0 Votes
    2 Posts
    2k Views
    A
    Same here, it's why the QLocalServer not listen with all rights (same on unix)
  • I can run command script via terminal but gui application does not....

    2
    0 Votes
    2 Posts
    1k Views
    T
    You will need to set up the environment for the QProcess. What you need to do there tends to depend a bit on the OS you are using. You will definitely need to set up PATH correctly, but might need more (e.g. to find all the libraries your application needs).
  • Toolbar (text under icons) font size.

    4
    0 Votes
    4 Posts
    4k Views
    A
    Also, Qt supports CSS-style theming as well. I bet it works on toolbars too!
  • Connecting with MySQL under windows

    3
    0 Votes
    3 Posts
    1k Views
    C
    oops...Sorry Sir...
  • Prevent app (with systray icon) from closing when last window is closed.

    4
    0 Votes
    4 Posts
    4k Views
    A
    Argh, sorry, havn't read you post exactly :) try "this":http://qt-project.org/doc/qt-4.8/qapplication.html#quitOnLastWindowClosed-prop: @qApp()->setQuitOnLastWindowClosed(false);@
  • QList and QSharedData

    2
    0 Votes
    2 Posts
    2k Views
    M
    And the answer is : NO! I'm gonna answer why, because every question in a forum should be answered for future references, but its a little technical (but not much). First, I found the description of a shared class on the page Implicit Sharing : bq. A shared class consists of a pointer to a shared data block that contains a reference count and the data. So a shared class is the size of a pointer, which match the Qlist description : bq. If T is itself a pointer type or a basic type that is no larger than a pointer, or if T is one of Qt's shared classes, then QList<T> stores the items directly in the pointer array. So i went through QT's sources and enlighted myself about the size of classes and I found this on google : bq. Size of a class object is nothing but it's non-static member data + if it has any virtual functions, then it's _vptr size + it's inherited data, if it is inherited from some class. So a shared class contains a single member (a pointer to its data struct or class) and many function members. The data struct contains a refcount and the data of the class. And that's exactly how QString (a shared class) is coded. So having used a QList of pointers in the first place would have been a lot less trouble, but learning such technical stuff is just way too awesome. Greg
  • Where is the source code ?

    11
    0 Votes
    11 Posts
    6k Views
    D
    Hi Stuart, All you need is Qt library, all the examples and tutorials are included in the library. QtCreator is just IDE, without Qt library, you can not develop Qt Application, and you can not find example or documentions. Regards, Debao
  • [SOLVED] QVariant's .toDouble() returns 0.0 incorrectly

    2
    0 Votes
    2 Posts
    3k Views
    K
    Do not worry. This happens ;-) Good to know that your problem is solved. Thanks for sharing the resolution. It is also good to leave your post here. May help other to check out their code again.
  • Load multiple files from directory in memory

    2
    0 Votes
    2 Posts
    2k Views
    T
    Just use a QFile or fstream, and loop over all the files in the directory, and open them 1 by 1...! then do everything you wanna do with them!
  • The function QGraphicsScene::itemAt problem

    2
    0 Votes
    2 Posts
    4k Views
    G
    Hi, Too bad that you didn't share the code that is not working... I think you're doing this really wrong and may have some serious trouble in future with your approach, however few good solutions that you may use: There are much better ways to determine the selected item... If you don't want to use the QGraphicsObject, allow your items to be really selected by setFlag(QGraphicsItem::ItemIsSelectable, true), now in event, iterate over items and check it by isSelected() Use QGraphicsObject Instead of QGraphicsItem, reimplement the mousePressEvent, put the emit some singal inside and catch the signal. Look at some sample code that I wrote for you (It's not about the code quality, I just want to give you an idea): header: @ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QtGui> class TextItem : public QGraphicsTextItem { Q_OBJECT public: TextItem( const QString & text, QGraphicsItem * parent = 0 ) : QGraphicsTextItem( text, parent ) { //Optional //setFlag(QGraphicsItem::ItemIsMovable, true); //setFlag(QGraphicsItem::ItemIsSelectable, true); } void mousePressEvent( QGraphicsSceneMouseEvent *e ) { qDebug() << __PRETTY_FUNCTION__; emit itemClicked(); QGraphicsTextItem::mousePressEvent( e ); } signals: void itemClicked(); }; namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: QGraphicsScene *scene; QGraphicsView *view; private slots: void onItemClicked(); }; #endif // MAINWINDOW_H @ source: @ #include "mainwindow.h" #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { view = new QGraphicsView(); scene = new QGraphicsScene(); view->setScene( scene ); view->setSceneRect( view->rect() ); scene->setSceneRect( view->rect() ); scene->setBackgroundBrush( Qt::white ); setCentralWidget( view ); TextItem *t = new TextItem( "Item 1" ); TextItem *t2 = new TextItem( "Item 2" ); scene->addItem( t ); scene->addItem( t2 ); t->setPos( scene->sceneRect().topLeft() ); t2->setPos( scene->sceneRect().center() ); QObject::connect( t, SIGNAL(itemClicked()), this, SLOT(onItemClicked()) ); QObject::connect( t2, SIGNAL(itemClicked()), this, SLOT(onItemClicked()) ); } void MainWindow::onItemClicked() { TextItem ti = qobject_cast<TextItem>( sender() ); if ( ti != 0 ) { qDebug() << PRETTY_FUNCTION << ti->document()->toPlainText(); } } @ Please note the "Optional" commented code, uncomment them to se the change. Of course you can use signal mapper and many more to get it better, it's just an idea. By the way. I strongly recommend the "Diagram Scene example":http://doc.qt.nokia.com/4.7-snapshot/graphicsview-diagramscene.html. Hope that helps.