Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • How better find class pointer by class name?

    7
    0 Votes
    7 Posts
    6k Views
    G
    [quote author="Maxim Prishchepa" date="1310458609"]I Have pointer to some class, then i need find some class(es) using this pointer(maybe current pointer is needed class, or parent pointer is needed class etc.) now i do that: @QMdiArea * mdi = NULL; QMainWindow * main = NULL; QObject * p = parent(); while(p != NULL){ QString str = p->metaObject()->className(); if(str == "QMdiArea"){ mdi = qobject_cast<QMdiArea *>(p); } if(str == "QMainWindow"){ main = qobject_cast<QMainWindow *>(p); } p = p->parent(); } if(mdi == NULL) return; if(main == NULL) return;@ [/quote] I would not use the class name to retreive this. JUst use a qobject_cast. If it returns 0, it did not fir. Then you are string compare free in your code (even qobject_cast does some internally...)
  • About paintEvent

    5
    0 Votes
    5 Posts
    4k Views
    G
    [quote author="qteruk" date="1310312780"] So, does it mean that the window system has stored the content when the window is obscured and then revealed ? Can I disable this ?[/quote] Hi, this is the so called double buffering of Qt. Qt has a pixel buffer for each top level widget and each widget draws to this buffer. After all widgets have finished their drawing, the double buffer is blitted to the screen which reduces flickeing and unnessacary repaints which always need calculation (clipping, etc). This feature can be disabled by some widghets attrinbutes, have a look at "QWidget::setAttribute":http://doc.qt.nokia.com/4.7/qwidget.html#setAttribute
  • Signals/Slots behavior review

    12
    0 Votes
    12 Posts
    6k Views
    C
    Lukas, thanks again. Your stuff is really good enough to create a wiki saving there.
  • [Proposal to Nokia/Qt] Create a "Qt Runtime"

    25
    0 Votes
    25 Posts
    11k Views
    T
    I voted yes. It has been said in the past in http://labs.qt.nokia.com/ that qt is going to be more modular. This purpose makes qt more modular.. Also i want to mention some benefits for the unix that something like this might have. Something like this (the proposal) can benefit distros which doesn't use binaries such as gentoo and slackware (they compile their binaries from the sources,a lot of time for Qt!) Also note that only KDE users and Qt programmers need the entire Qt,all the others,they just need some modules of it(Qt frameworks),why these users should install/compile the entire Qt. Don't take me wrong,but someone who needs just some Qt modules can blame the Qt frameworks that forces his to install in his system the entire Qt. Moreover,Qt is going to be more "open" (Qt 5),so proposals like these will not make Qt frameworks more windows friendly,(at least not with the bad meaning of it).Actually the otherwise will happen,more modular Qt means more Qt in windows systems,so when people will start searching for more (bigger) Qtish stuff they will come across to projects like KDE,meego which are of course unix friendly.:)
  • [solved]ProxyModel not working

    3
    0 Votes
    3 Posts
    2k Views
    P
    solved by myself... the problem was that I've omitted the const in the data() function signature, so superclass method was called. thanks anyway
  • Xml file to qml dynamic list

    3
    0 Votes
    3 Posts
    3k Views
    G
    sorry. i need it to be open when the user click on the element to show the children nodes it need to be shown as a tree model(but to load the data from the XML file only when the user ask for it)
  • [solved]Mapping a QComboBox displaying multiple columns

    3
    0 Votes
    3 Posts
    4k Views
    P
    what a wonderful thing I've discovered! =D thanks a lot
  • [Solved] Problem with QSignalMapper and QAction never triger the Slot

    9
    0 Votes
    9 Posts
    6k Views
    U
    ok ludde after looking again in my code and moving the QAction to set only once , its solved my problem Thanks
  • 0 Votes
    5 Posts
    5k Views
    D
    not only a tag. Please update title with [solved]
  • Signals and slots with multiple widgets, chat example

    8
    0 Votes
    8 Posts
    6k Views
    L
    You cannot emit a signal to a specifc slot, but keep in mind that slots are ordinary methods which can be called through a signal, but don't have to. So instead of sending a signal to a slot just call the slot directly. If you are crossing thread boundaries or you want to call the slot through the event loop for any other reason you can invoke the slot using the meta object system and "QMetaObect::invokeMethod()":http://doc.qt.nokia.com/latest/qmetaobject.html#invokeMethod which is basically the same as sending a signal to a specific slot / object.
  • 0 Votes
    1 Posts
    953 Views
    No one has replied
  • QProgressBar and stylesheet: best way to add a vertical bar

    3
    0 Votes
    3 Posts
    4k Views
    J
    I finally took a few minutes to subclass my progressbar. I added a QRubberBand to handle a min and max threshold (for hysteresis). Works great for little to no efforts! I am now wondering if I can set a styleSheet on a QRubberBand to alter color and opacity!
  • [Solved] Accepted signal from QDialogButtonBox

    3
    0 Votes
    3 Posts
    6k Views
    D
    Thanks mlong this is how I ended up doing it: @void LoginScreen::accept() { if(LoginToDB()) { done(QDialog::Accepted); } } bool LoginScreen::LoginToDB() { bool ret = w->LogintoMusicDB(ui->userLineEdit->text(), ui->passwordLineEdit->text()); if(!ret) { ui->labelError->setText("Could not log into database!"); ui->userLineEdit->setText(""); ui->passwordLineEdit->setText(""); return false; } return true; }@
  • Documentation without Qt Assistant

    8
    0 Votes
    8 Posts
    6k Views
    S
    I'm currently working on the implementation of the documentation links. It is possible using the whatsThis or modal dialog, but I think the programming and documenting workflow could be improved much. Rather than having to enable context help and write the text for every UI element that is added, context help should be available by default. Developers tend to forget to add context help support and it can only be added by modifying the code. It would be better to have the context text and links externalized (I have read into localization, but there a first text is always required, from which is then translated). Our old implementation was: @ class SomeUIElement { Q_OBJECT // context help action is added in constructor SomeUIElement() { QString vHelpText = ...; QAction* vContextHelpAction = new QAction(QIcon(""), tr(vHelpText), this); connect(vContextHelpAction, SIGNAL(triggered()), this, SLOT(OnContextHelp())); addAction(vContextHelpAction); setContextMenuPolicy(Qt::ActionsContextMenu); } void OnContextHelp() { QString vLink = GetContextLinkFor("myClassIdentifier"); OpenHtmlFile(vLink); } } @ A first improvement is that I could replace "myClassIdentifier" by QString vClassName = metaObject()→className(); and use this as the identifier. Like that, the OnContextHelp method is the same for every class. In a second step, I thought I could create my own version of QWidget @ class MyContextHelpEnabledWidget { void OnContextHelp() { ... } } @ and make all my user interface elements inherit from MyContextHelpEnabledWidget instead of QWidget. But this works only for the dialogs I create. I would prefer to have this on a "core UI element" level, i.e. for every button, dropdown, table, etc. but then I do not know how I could have QButton inherit from MyContextHelpEnabledWidget instead of QWidget. (I guess this is too much hacking anyway). In short again, how can I implement a default context help for every button in my application?
  • QGridLayout: widgets don't align properly

    12
    0 Votes
    12 Posts
    12k Views
    EddyE
    I tested your first code on windows 7 and didn't see the behaviour you have. Layout margins use the theme defaults. But i cannot test it on mac. The only thing i could think of is the contentsmargins of your gridlayout. Anyway, i'm glad i could help.
  • 0 Votes
    4 Posts
    4k Views
    M
    No problem! Good luck!
  • [SOLVED] StyleSheets and HTML code

    4
    0 Votes
    4 Posts
    2k Views
    A
    Changed [CLOSED] tag to [SOLVED], since the topic is not actually closed.
  • I want to add image to the items in the table view

    10
    0 Votes
    10 Posts
    12k Views
    M
    Thanks Andre
  • 0 Votes
    3 Posts
    2k Views
    A
    Indeed, like Lukas said: please stick to a single topic. Closed.
  • How to hide the columns of QTableWidget at runtime

    2
    0 Votes
    2 Posts
    4k Views
    L
    What about "hideColumn()":http://doc.qt.nokia.com/latest/qtableview.html#hideColumn?