Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.8k Posts
  • Cannot subclass QObject

    10
    0 Votes
    10 Posts
    10k Views
    C
    Included files are recursively processed and may themselves drag in other declarations. You can forward declare a class, which is sufficient to allow declaring a pointer to the class but not sufficient to access the class members from the implementation. My guess is that some header you were including contains something like: @ class song; // a forward declaration class Foo { ... private: song *m_song; // that allows this }; @ in order to declare a pointer to song. The compiler knows song exists, and can create pointer to one, but does not know anything of song's implementation including inheritance.
  • Set a function to affect to entire sistem

    4
    0 Votes
    4 Posts
    2k Views
    ?
    Maybe he speaks of something like this: http://qt-project.org/forums/viewthread/15308/
  • Where to put images (.png) to work wit Qt project

    7
    0 Votes
    7 Posts
    37k Views
    G
    mbourguel, please wrap code in @-tags. this way you make sure that the code is formatted nicely. I've don it four you in your previous posts, but please keep in mind for further posts. Thank you. Is your problem finally solved or do you have an further questions on the resource system? Seems like you've already discovered how the aliasing facilities in the .qrc files work.
  • 0 Votes
    2 Posts
    2k Views
    ?
    Ops, I obviously need to work on my focus skills, totally missed the pointAtPercent method for QPainterPath. Problem solved!
  • [Solved] Inserting lineEdit contents into database

    10
    0 Votes
    10 Posts
    8k Views
    O
    You can use prepared queries everywhere : @ QSqlQuery q; q.prepare("DELETE FROM Persons WHERE firstName=:firstName"); q.bindValue(":firstName", nameLineEdit->text()); if (q.exec()) { } @
  • XK_question generates asterisk key

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • [SOLVED]drawText() on multiple line

    6
    0 Votes
    6 Posts
    18k Views
    C
    [quote author="Vetryaspa" date="1331733990"] [quote author="cincirin" date="1331726961"]Use "this overloaded drawText":http://qt-project.org/doc/qt-4.8/qpainter.html#drawText-10 with Qt::TextWordWrap flag[/quote] Run!!! Tanx so much!!![/quote] You are welcome :-)
  • Qt 4.6 and OpenGL ES 2.0

    2
    0 Votes
    2 Posts
    2k Views
    L
    How about "this page":http://doc.qt.nokia.com/4.6/windowsce-opengl.html?
  • Creating new widgets/windows

    3
    0 Votes
    3 Posts
    1k Views
    K
    I was considering should we create and delete it everytime or just show and hide. Probably the answer would be 'Depends' based on the scenario. All my previous applications (Non - QT) were behaving in the creation and deletion way. I am bit confused if I need to use the show and hide,. what I need to be doing if the widgets are too big (in terms of memory)
  • How to close all QMessageBoxes

    15
    0 Votes
    15 Posts
    9k Views
    A
    I stand corrected. It does work. Thanks for your patience.
  • Restarting an application

    2
    0 Votes
    2 Posts
    1k Views
    L
    If your MainWindow is self-contained just create another MainWindow instance and drop the current one. All connections of a QObject are automatically disconnected if the object is deleted.
  • Pasting Graphics From Word for Mac into Qt

    3
    0 Votes
    3 Posts
    2k Views
    E
    Thanks for the suggestion. Unfortunately, the issue seems to lie at a level below QMimeData. QMimeData never gets to see the data attached to com.apple.pict so there is noting to retrieve.
  • QXMLQuery problems

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • Resizing a QLineEdit to contents

    2
    0 Votes
    2 Posts
    9k Views
    J
    I think you need override sizeHint() by subclassing QLineEdit. see the qt source(qlineedit.cpp) @ . . /*! Returns a recommended size for the widget. The width returned, in pixels, is usually enough for about 15 to 20 characters. */ QSize QLineEdit::sizeHint() const { Q_D(const QLineEdit); ensurePolished(); QFontMetrics fm(font()); int h = qMax(fm.height(), 14) + 2d->verticalMargin + d->topTextMargin + d->bottomTextMargin + d->topmargin + d->bottommargin; int w = fm.width(QLatin1Char('x')) * 17 + 2d->horizontalMargin + d->leftTextMargin + d->rightTextMargin + d->leftmargin + d->rightmargin; // "some" QStyleOptionFrameV2 opt; initStyleOption(&opt); return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). expandedTo(QApplication::globalStrut()), this)); } /*! Returns a minimum size for the line edit. The width returned is enough for at least one character. */ QSize QLineEdit::minimumSizeHint() const { Q_D(const QLineEdit); ensurePolished(); QFontMetrics fm = fontMetrics(); int h = fm.height() + qMax(2*d->verticalMargin, fm.leading()) + d->topmargin + d->bottommargin; int w = fm.maxWidth() + d->leftmargin + d->rightmargin; QStyleOptionFrameV2 opt; initStyleOption(&opt); return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). expandedTo(QApplication::globalStrut()), this)); } . . @ It seems that preffered/minimum sizes are not considering actual content.
  • QMenuBar in QMainWindow Styling issue

    6
    0 Votes
    6 Posts
    5k Views
    J
    Though quite old topic, I found how to control the menubar's painting via palette in this case. The color of "File" menu while mouse is over it is QPalette::Higlight color, so you just can change it. see.. in the qwindowsxpstyles.cpp code @ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *p, const QWidget *widget) const { . . case CE_MenuBarItem: if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { if (mbi->menuItemType == QStyleOptionMenuItem::DefaultItem) break; bool act = mbi->state & State_Selected; bool dis = !(mbi->state & State_Enabled); QBrush fill = mbi->palette.brush(act ? QPalette::Highlight : QPalette::Button); QPalette::ColorRole textRole = dis ? QPalette::Text: act ? QPalette::HighlightedText : QPalette::B . . @ The 'fill' brush is the one that make your menubar ugly in your case(but it is due to your desktop configuration not Qt, i think). I just did @ QPalette palette = this->menuBar()->palette(); palette.setBrush(QPalette::Highlight, QBrush(QColor(100,100,100,100))); @ and feel like it is much better in the gradient background.
  • Prevent screensaver and screen dimming

    1
    0 Votes
    1 Posts
    3k Views
    No one has replied
  • Cannot Deploy Executable (nmake problems)

    6
    0 Votes
    6 Posts
    3k Views
    H
    [quote author="leon.anavi" date="1331585800"]I have a simple tutorial about static builds of Qt apps. It's available at "Qt Dev Net wiki":http://qt-project.org/wiki/Build_Standalone_Qt_Application_for_Windows and "my personal website":http://www.anavi.org/article/140/. Instead of nmake you can use on MinGW. I personally prefer it.[/quote] I really hate posting 3 in a row... If a mod could delete the previous 2, that would be nice as I don't want everone to think because I am new I don't know how to post. But I was trying your tutorial, and also had trouble. Using Microsoft Visual Studio: qmake is not found... I have no idea what to do. I have the whole Qt SDK installed. Here is my output: http://pastie.org/3587651 Using Mingw32: I don't know if I am really stupid or something, but when I go into a command prompt and type 'mingw32-make sub-src', it says mingw32-make is not a recognized command. I feel like I have to cd to a directory, but I don't know. Thanks again, hetelek.
  • QPrinter: wrong margins/page width

    3
    0 Votes
    3 Posts
    5k Views
    H
    OK. I think that is the Qt problem because this WIN32 code works great (I have HP printer to): @PRINTDLG pd; ZeroMemory(&pd, sizeof(PRINTDLG)); pd.lStructSize = sizeof(PRINTDLG); //pd.hwndOwner = m_hWnd; pd.hDevMode = NULL; pd.hDevNames = NULL; pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC; pd.nCopies = 1; pd.nFromPage = 0xFFFF; pd.nToPage = 0xFFFF; pd.nMinPage = 1; pd.nMaxPage = 0xFFFF; if (!PrintDlg(&pd)) { QMessageBox::warning(0,"Problem", "Cos z drukarka"); exit(0); } int LM = 0.5GetDeviceCaps(pd.hDC, LOGPIXELSX); int TM = 0.5GetDeviceCaps(pd.hDC, LOGPIXELSY); int LO = LM - GetDeviceCaps(pd.hDC, PHYSICALOFFSETX); int RO = LM - (GetDeviceCaps(pd.hDC, PHYSICALWIDTH) - GetDeviceCaps(pd.hDC, PHYSICALOFFSETX) - GetDeviceCaps(pd.hDC, HORZRES)); int TO = TM - GetDeviceCaps(pd.hDC, PHYSICALOFFSETY); int BO = TM - (GetDeviceCaps(pd.hDC, PHYSICALHEIGHT) - GetDeviceCaps(pd.hDC, PHYSICALOFFSETY) - GetDeviceCaps(pd.hDC, VERTRES)); if (LO<0) LO = 0; if (RO<0) RO = 0; if (TO<0) TO = 0; if (BO<0) BO = 0; int PW = GetDeviceCaps(pd.hDC, HORZRES) - (LO+RO); int PH = GetDeviceCaps(pd.hDC, VERTRES) - (TO+BO); qDebug() << "margins: " << LM << TM; qDebug() << "offsets: " << LO << RO << TO << BO; qDebug() << "width, height: " << PW << PH; qDebug() << "width, height2: " << GetDeviceCaps(pd.hDC, HORZRES) << GetDeviceCaps(pd.hDC, VERTRES); DOCINFO di; di.cbSize = sizeof(DOCINFO); di.lpszOutput = (LPTSTR)NULL; di.fwType = 0; StartDoc (pd.hDC, &di); StartPage(pd.hDC); // OUR RECTANGLE !!! Rectangle(pd.hDC, LO, TO, LO+PW, TO+PH); EndPage(pd.hDC); EndDoc(pd.hDC); DeleteDC(pd.hDC);@ Maybe the solution is in to mix WIN32 code with Qt?
  • Modification of Qt source code under LGPL

    2
    0 Votes
    2 Posts
    1k Views
    EddyE
    This "thread":http://qt-project.org/forums/viewthread/8241 has a splendid explanation. Thanks to Andre
  • MemoryManagement of QGraphicsItems

    3
    0 Votes
    3 Posts
    4k Views
    ?
    Why not keep the "free" items inside some container, the scene manages the items that are in it, you manage the container that holds the free items, shift items back and forth and so on...