Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.9k Posts
  • Qt application running with high CPU usage on Mac OS X

    1
    0 Votes
    1 Posts
    3k Views
    No one has replied
  • [SOLVED] Qt Visual Studio Add-in, Signal & Slots problems

    4
    0 Votes
    4 Posts
    11k Views
    A
    Please add "[SOLVED]" left to the topic subject.
  • Forward Declaration error

    26
    0 Votes
    26 Posts
    21k Views
    P
    hi... Everything is working fine until when I write in main. In main I included one of the subdirectory's .h file and wrote some function like this I am posting here both the codes of main and that directory.... Error I am getting is : /home/pragati/MultiFuncTester/Components/Main/Source/Main.cpp:-1: error: undefined reference to `Start::Startup::Startup()' /home/pragati/MultiFuncTester/Components/Main/Source/Main.cpp:-1: error: undefined reference to `Start::Startup::GuiInit()' /home/pragati/MultiFuncTester/Components/Main/Source /Main.cpp:-1: error: undefined reference to `Start::Startup::~Startup()' Similiar error for GuiInit.... Start.h @ #ifndef START_H #define START_H #include "../../DMM/Include/DMM.h" /****************************************************************************/ /** \brief This class handles the initialization of the user interface. / /***************************************************************************/ namespace Start { class Startup : public QObject { Q_OBJECT public: Startup(); virtual ~Startup(); void GuiInit(); private: DMM::DMMMenu *MainWindow; }; } #endif // START_H @ Start.cpp @ #include "../../Start/Include/Start.h" namespace Start { Startup::Startup() : QObject() { // // GUI components MainWindow = new DMM::DMMMenu(); } /***************************************************************************/ /! \brief Initializes the user interface / /***************************************************************************/ void Startup::GuiInit() { MainWindow->show(); } } @ Main.cpp @ #include "../../Start/Include/Start.h" #include <QApplication> #include <QtGui> int main(int argc, char *argv[]) { QApplication app(argc, argv); Start::Startup start; start.GuiInit(); return app.exec(); } @
  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • QGLWidget displayed only in QScrollArea

    5
    0 Votes
    5 Posts
    2k Views
    Z
    Resizing the square in the grid after the QGLwidget was added solved the problem. I called setColumnMinimumWidth and setRowMinimumHeight, but I don't know why is this needed...
  • Popup with toggle button

    5
    0 Votes
    5 Posts
    7k Views
    J
    I also tried to use the QComboBox with a QTreeWidget. It basically works because you can set the view of the QComboBox: @ myComboBox->setModel(treeWidget->model()); myComboBox->setView(treeWidget); myComboBox->setFrame(false); @ However whenever I click on something in the TreeView the popup is hidden. This made sense for the entries in the QListView, which the QComboBox uses by default but not for the TreeView. I want it to only hide if the user double-clicks an entry and so far I could not figure out how to do this. Closing happens in the event filter of the QComboBoxPrivateContainer. So I tried first to install an event filter which returns true on the MouseReleaseEvent on the view. @FilterObj *filter = new FilterObj(m_mainWin); myComboBox->view()->installEventFilter(filter);@ The problem is that the eventFilter on the QComboBoxPrivateContainer gets called first. So I also tried to overwrite QCombBoxes event(..) method but also w/o any success. To me it seems that I would need to modify the QComboBoxPrivateContainer in order to change this behavior. However because it is private I am not supposed to do this. For me this raises two questions: How can I figure out the order in which an event is processed? Which widget gets it first and to which widget is it passed? Is there another way to change the MouseButtonRelease event-processing behavior of the QComboBox?
  • Measuring CPU usage and internet bandwidth

    5
    0 Votes
    5 Posts
    5k Views
    M
    Yeah, as said before, there probably isn't a platform independent solution for this. GetSystemTimes() is the way to do it on the Windows platform. You'd have to look for a different way to get the CPU time counters on Linux, e.g. by reading "/proc/stat". Anyway, the basic idea on how to calculate the "CPU usage" should be the same!
  • [SOLVED] Need help with regular expression

    3
    0 Votes
    3 Posts
    2k Views
    A
    have done this without regexp. @ long chk_version(QString ver) { return ver.contains(' ')?ver.left(ver.indexOf(' ')).remove('.').toLong():ver.remove('.').toLong(); } @
  • How to deal with foreign key in Qt?

    2
    0 Votes
    2 Posts
    1k Views
    C
    errorMsg is null or otherwise invalid.
  • Setting an image as the background of th UI

    6
    0 Votes
    6 Posts
    5k Views
    V
    Do set background image for a ui. you need to add resoucre file in the project's floder and add the resorce file name to the .pro file ( RESOURCES += resource.qrc ) content of resource.qrc <RCC> <qresource prefix="/new/icon"> <file>imagefilename</file> </qresource> </RCC> then go to the ui and select change style sheet add resource to it background-image: url(:/filepath);
  • How to use Qt::CaseInsensitive in Qtablewidget data sorting?

    2
    0 Votes
    2 Posts
    5k Views
    C
    On my machine sorting in QTableWidget is case insensitive by default, so I assume you want a case sensitive sort: that is words starting with A-Z sort before words starting a-z. Make a subclass of QTableWidgetitem and override the default operator<() to do a case-sensitive comparison. Use that subclass for the items you add to the table. Here is a complete program. The left column sorts one way, the right column the default. @#include <QtGui> #include <QDebug> class MyItem: public QTableWidgetItem { public: MyItem(const QString &text, int type = Type): QTableWidgetItem(text, type) { } bool operator< ( const QTableWidgetItem & other ) const { return (QString::compare( data(Qt::DisplayRole).toString(), other.data(Qt::DisplayRole).toString(), Qt::CaseSensitive ) < 0 ); } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); QStringList values; values << "Z" << "b" << "B" << "a" << "A"; QTableWidget tw(5,2); for (int r = 0; r < 5; ++r) { tw.setItem(r, 0, new MyItem(values.at(r))); // left column uses our sorting tw.setItem(r, 1, new QTableWidgetItem(values.at(r))); // right column uses default } tw.setSortingEnabled(true); tw.show(); return app.exec(); } @
  • 0 Votes
    3 Posts
    2k Views
    B
    Thanks, I don't think so. I believe it would also require a QApplication instance to exist before I can create a QEventLoop. But I will test it. I also looked for a "starting" signal from QApplication that I could connect to. But the same chicken and the egg problem: to connect to a signal, you must know the sender. At the time I want to connect, the QApplication hasn't been created. I also just tried a Python threading.Timer() that would delay a short time and then I would call QApplication.instance() to get a reference to the event loop. But it didn't work, I suppose because the Timer is its own OS thread, different from the thread the QApplication instance is in. That would have been portable. So now I am trying UNIX signal SIGALRM, which is not portable. I suppose the easiest thing is to require one change to the SUT: add a line to call the testing tool at the appropriate time.
  • Qt3D and post-processing

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    4 Posts
    2k Views
    F
    Wrote my own doc generator. Never mind.
  • Formatting

    5
    0 Votes
    5 Posts
    2k Views
    V
    ok thanks for Ur comment i will correct it
  • Console Application Help

    4
    0 Votes
    4 Posts
    4k Views
    M
    If it is okay for you that your GUI app always runs with Admin privileges (will trigger an UAC dialog on application startup and will additionally require Non-Admin users to enter an Admin password!), then you can simply set the UAC Execution Level to "requireAdministrator". Then your GUI app will either run with full Admin privileges or not run at all. This means you will be able to install services and you also will be able to call other apps (Console or GUI doesn't matter) that need an UAC Execution Level of "requireAdministrator". Calling an app that requires elevation from a process that already has been elevated will NOT trigger an UAC dialog again. Another option would be to let your "main" GUI app run with an UAC Execution Level of "asInvoker", which will avoid the UAC dialog and will allow everybody to start your GUI app. Of course then your GUI app won't be able to install services itself, because it has not been elevated. And it also won't be able to run other apps that need an UAC Execution Level of "requireAdministrator" via CreateProcess() or QProcess. That's because CreateProcess() will simply fail, when you try to run a child-process that needs elevation from a non-elevated parent-process. Bummer! But you still can use ShellExecute() or ShellExecuteEx() instead - they will of course trigger an UAC dialog at the point where the child-process is about to be created. But it works. So my suggestion would be: Make a GUI app that runs with "asInvoker" Execution Level and make an additional Console app that performs the "administrative" tasks and that runs with "requireAdministrator" Execution Level. The Console app would be called from the GUI app via ShellExecute() or ShellExecuteEx() when needed. <HINT> Actually it would be possible that a non-elevated instance of the GUI app creates a second elevated instance of itself in the background. The second instance can then do the "administrative" tasks that the first instance can't do. You can explicitly elevate an application (if its Manifest doesn't enforce elevation) by creating it via ShellExecute() and using the "runas" verb. This way you don't need a second (console) app. </HINT>
  • [Solved]What is qApp

    3
    0 Votes
    3 Posts
    6k Views
    S
    check "this":http://qt-project.org/doc/qt-4.8/qapplication.html#qApp and also "this":https://www.google.ae/#hl=en&gs_nf=1&pq=qapp&cp=7&gs_id=19&xhr=t&q=qApp+qt&pf=p&sclient=psy-ab&oq=qApp+qt&aq=0&aqi=g2g-K2&aql=&gs_l=&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&fp=b003561a3680d46f&biw=1486&bih=732
  • Does anyone know any text to speech or speech to text conversion API's???

    10
    0 Votes
    10 Posts
    6k Views
    D
    Out of interest, does anyone know if there is any Braille support for Qt? I need speech and Braille.
  • Replace text from where user left the cursor

    3
    0 Votes
    3 Posts
    1k Views
    G
    You could work with the find() methods of the [[Doc:QTextDocument]] attached to the QTextEdit. Those methods take a [[Doc:QTextCursor]] or int argument as the starting point of the search.
  • Segmentation Fault through signal SIGSEGV

    3
    0 Votes
    3 Posts
    5k Views
    G
    Why use a heavy weighted object like the signal mapper here? A much more simple approach would be to use a small protected slot that emits your signal: @ class CustomButton : public QPushButton { Q_OBJECT public: CustomButton(QString name,int num, QWidget *parent = 0); signals: void clicked(int pos); private slots: void emitClickedWithInt(); private: int myNumber; }; CustomButton::CustomButton(QString name,int num, QWidget *parent) : QPushButton(name, parent), myNumber(num) { connect(this, SIGNAL(clicked()), this, SLOT(emitClickedWithInt())); } void CustomButton::emitClickedWithInt() { emit clicked(myNumber); } @